iOS開發(fā)應(yīng)用里Twitter使用
作者:佚名
本文介紹的是iOS開發(fā)應(yīng)用里Twitter使用方法,很詳細(xì)的介紹了Twitter方法的使用,先來(lái)看內(nèi)容詳解。
iOS開發(fā)應(yīng)用里Twitter使用是本文要介紹的內(nèi)容,Twitter現(xiàn)在歐美地區(qū)極其火爆,如果各位開發(fā)者想在應(yīng)用中增加 Twitter 功能,可以看一下許靖昕先生在博客中分享的代碼。
- - (void) postToTwitter
- {
- // Since this will be launched in a separate thread, we need
- // an autorelease pool
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:
- [NSURL URLWithString:@"http://TWITTER_ACCOUNT:PASSWORD@twitter.com/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.");
- // Release pool
- [pool release];
- }
- [NSThread detachNewThreadSelector:@selector(postToTwitter)
- toTarget:self withObject:nil];
小結(jié):iOS開發(fā)應(yīng)用里Twitter使用的內(nèi)容介紹完了,希望通過本文對(duì)你有所幫助!
責(zé)任編輯:zhaolei
來(lái)源:
互聯(lián)網(wǎng)