我使用这个代码小块在Twitter上张贴张贴到Twitter,与真正的凭据到位“mytwitterloginname”和“mytwitterpassword”占位符:无法从我的iPhone应用程序
void _StartTwitter()
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:@"http://mytwitterloginname:[email protected]/statuses/update.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
// The text to post
NSString *msg = @"testing";
// Set the HTTP request method
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[[NSString stringWithFormat:@"status=%@", msg]
dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse *response;
NSError *error;
if ([NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error] != nil)
NSLog(@"Posted to Twitter successfully.");
else
NSLog(@"Error posting to Twitter.");
}
但即使我的控制台说这个帖子是成功的,它仍然没有发生。
任何人都可以帮助我找到问题所在?,谢谢。
您需要检查返回的响应对象。仅仅因为连接成功并不意味着所请求的操作是成功的。 – Nick 2011-02-24 20:06:48