iOS應(yīng)用程序 Twitter開發(fā)代碼
iOS應(yīng)用程序 Twitter開發(fā)代碼是本文要介紹的內(nèi)容,先來了解一下Twitter,它是國外的一個社交網(wǎng)絡(luò)及微博客服務(wù)的網(wǎng)站。它利用無線網(wǎng)絡(luò),有線網(wǎng)絡(luò),通信技術(shù),進行即時通訊,是微博客的典型應(yīng)用。
Twitter允許用戶將自己的***動態(tài)和想法以短信形式發(fā)送給手機和個性化網(wǎng)站群,而不僅僅是發(fā)送給個人。2006年,博客技術(shù)先驅(qū)blogger.com創(chuàng)始人埃文·威廉姆斯(Evan Williams)創(chuàng)建的新興公司Obvious推出了大圍脖服務(wù)。在最初階段,這項服務(wù)只是用于向好友的手機發(fā)送文本信息。2006年底,Obvious對服務(wù)進行了升級,用戶無需輸入自己的手機號碼,而可以通過即時信息服務(wù)和個性化Twitter網(wǎng)站接收和發(fā)送信息。
Twitter 現(xiàn)在歐美地區(qū)極其火爆,如果各位開發(fā)者想在應(yīng)用中增加 Twitter 功能,可以看一下許靖昕先生在博客中分享的代碼。
代碼地址:http://blog.csdn.net/cloudhsu/article/details/6048626
- - (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];
 - - (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應(yīng)用程序 Twitter開發(fā)代碼的內(nèi)容介紹完了,希望本文對你有所幫助。
本文來自:http://www.cocoachina.com/iphonedev/sdk/2010/1202/2431.html















 
 
 

 
 
 
 