//TWITTER BLACK MAGIC
NSMutableURLRequest *theRequest =[NSMutableURLRequest
requestWithURL:[NSURL URLWithString :
@"http://YOUR_TWITTER_UESERNAME:YOUR_TWITTER_PASSWORD@twitter.com/statuses/update.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[[NSString stringWithFormat:@"status=%@",theMessage]
dataUseEncoding:NSASCIIStringEncoding]];
NSURLResponse* response;NSError*error;
NSData result = [NSURLConnection sendSynchronousRequest:theRequest
returningResponse:&response error:&error];
NSLog(@"%@",[[[NSString alloc]initWithData:result
encoding:NSASCIIStringEncoding]autorelease]);
//END TWITTER BLACK MAGIC
Twitter API 发推文示例
本文提供了一个使用 Objective-C 编写的示例代码,演示如何通过 Twitter API 发布一条新的推文。代码中详细展示了如何设置请求参数、进行身份验证及发送请求的过程。
16

被折叠的 条评论
为什么被折叠?



