IOSIn application developmentTwitterDevelopment code is the content to be introduced in this article,TwitterIt is extremely popular in Europe and America. If developers want to addTwitterFunction. You can refer to the Code shared by Mr. Xu jingxin in his blog.
- - (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];
Summary:IOSApplication DevelopmentTwitterThe content of the development code has been introduced. I hope this article will help you!