最終更新:2009-07-28 (火) 23:33:45 (3618d)  

NSMutableURLRequest はてなブックマークを見る
Top / NSMutableURLRequest

TwitterにPOST

- (void)update:(NSString *)tweet {
	static NSString *udpateUrl = @"http://%@:%@@twitter.com/statuses/update.xml";

	NSString *url;
	NSString *postString;
	NSMutableURLRequest *request;

	url = [NSString stringWithFormat:udpateUrl, username,password];
	postString = [NSString stringWithFormat:@"status=%@&source=%@",
						[tweet stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
						clientName]; 

	url = [url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

	request = [[[NSMutableURLRequest alloc] init] autorelease];
	[request setURL:[NSURL URLWithString:url]];
	[request setCachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData];
	[request setTimeoutInterval:20];
	[request setHTTPShouldHandleCookies:FALSE];
        [request setHTTPMethod:@"POST"];
	if (postString) {
		[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
	}
	NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

}

http://iphone.longearth.net/2009/07/06/【iphone】【objective-c】twitterにつぶやきをポストする/

関連