iOS应用程序 Twitter开发代码

移动开发 iOS
本文介绍的是iOS应用程序 Twitter开发代码,主要介绍了Twitter其中的代码与大家分享,不如先来看内容。

iOS应用程序 Twitter开发代码是本文要介绍的内容,先来了解一下Twitter,它是国外的一个社交网络及微博客服务的网站。它利用无线网络,有线网络,通信技术,进行即时通讯,是微博客的典型应用。

Twitter允许用户将自己的***动态和想法以短信形式发送给手机和个性化网站群,而不仅仅是发送给个人。2006年,博客技术先驱blogger.com创始人埃文·威廉姆斯(Evan Williams)创建的新兴公司Obvious推出了大围脖服务。在最初阶段,这项服务只是用于向好友的手机发送文本信息。2006年底,Obvious对服务进行了升级,用户无需输入自己的手机号码,而可以通过即时信息服务和个性化Twitter网站接收和发送信息。

Twitter 现在欧美地区极其火爆,如果各位开发者想在应用中增加 Twitter 功能,可以看一下许靖昕先生在博客中分享的代码。

代码地址:http://blog.csdn.net/cloudhsu/article/details/6048626

 

  1. - (void) postToTwitter  
  2. {  
  3.   // Since this will be launched in a separate thread, we need  
  4.   // an autorelease pool  
  5.   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  
  6.    
  7.   NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:  
  8.     [NSURL URLWithString:@"http://TWITTER_ACCOUNT:PASSWORD@twitter.com/statuses/update.xml"]   
  9.     cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];  
  10.    
  11.   // The text to post  
  12.   NSString *msg = @"testing";  
  13.    
  14.   // Set the HTTP request method  
  15.   [request setHTTPMethod:@"POST"];  
  16.    
  17.   [request setHTTPBody:[[NSString stringWithFormat:@"status=%@", msg]   
  18.     dataUsingEncoding:NSASCIIStringEncoding]];  
  19.    
  20.   NSURLResponse *response;  
  21.   NSError *error;  
  22.    
  23.   if ([NSURLConnection sendSynchronousRequest:request   
  24.       returningResponse:&response error:&error] != nil)  
  25.     NSLog(@"Posted to Twitter successfully.");  
  26.   else   
  27.     NSLog(@"Error posting to Twitter.");   
  28.    
  29.   // Release pool  
  30.   [pool release];   
  31. }     
  32. [NSThread detachNewThreadSelector:@selector(postToTwitter)  
  33.    toTarget:self withObject:nil];  
  34. - (void) postToTwitter  
  35. {  
  36.   // Since this will be launched in a separate thread, we need  
  37.   // an autorelease pool  
  38.   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  
  39.   NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:  
  40.     [NSURL URLWithString:@"http://TWITTER_ACCOUNT:PASSWORD@twitter.com/statuses/update.xml"]   
  41.     cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];  
  42.   // The text to post  
  43.   NSString *msg = @"testing";  
  44.    
  45.   // Set the HTTP request method  
  46.   [request setHTTPMethod:@"POST"];  
  47.    
  48.   [request setHTTPBody:[[NSString stringWithFormat:@"status=%@", msg]   
  49.     dataUsingEncoding:NSASCIIStringEncoding]];  
  50.    
  51.   NSURLResponse *response;  
  52.   NSError *error;  
  53.    
  54.   if ([NSURLConnection sendSynchronousRequest:request   
  55.       returningResponse:&response error:&error] != nil)  
  56.     NSLog(@"Posted to Twitter successfully.");  
  57.   else   
  58.     NSLog(@"Error posting to Twitter.");   
  59.    
  60.   // Release pool  
  61.   [pool release];   
  62. }   
  1. [NSThread detachNewThreadSelector:@selector(postToTwitter)  
  2.    toTarget:self withObject:nil]; 

小结:iOS应用程序 Twitter开发代码的内容介绍完了,希望本文对你有所帮助。

本文来自:http://www.cocoachina.com/iphonedev/sdk/2010/1202/2431.html

责任编辑:zhaolei 来源: CocoaChina
相关推荐

2011-08-11 16:50:04

iOSTwitter

2011-08-08 13:26:48

iOS开发 Twitter

2009-07-07 00:01:32

Twitter应用

2013-01-11 15:06:13

iOS开发移动应用iPhone

2011-07-18 10:21:04

iOS Visual Stu iphone

2013-01-11 15:24:02

iOS开发移动应用iPhone

2013-01-11 14:45:43

iOS开发移动应用iPhone

2012-03-15 15:35:51

iUI框架EclipseiOS Web

2022-08-02 16:33:54

网络安全密钥数据泄漏

2013-01-11 14:33:14

iOS开发移动应用iPhone

2011-07-18 10:00:47

iPhone iOS Visual Stu

2013-02-21 14:15:41

开发Tizen

2013-02-21 14:14:40

开发Tizen

2012-02-08 15:06:31

ibmdw

2022-09-19 00:37:13

SaaS云计算开发

2020-02-20 12:50:47

后端代码应用程序

2013-01-11 15:36:09

iOS开发移动应用iPhone

2013-11-19 15:35:01

2011-05-11 10:58:39

iOS

2014-04-02 09:56:13

iOS应用减小安装包
点赞
收藏

51CTO技术栈公众号