0
我试图让下面的代码运行(它来自Heads First iPhone Development的书 - 第81页),它是一个推特应用程序,当你按下按钮发送一个简单的短信,Twitter的:发送消息给Twitter创建一条错误消息
//TWITTER BLACK MAGIC
NSMutableURLRequest *theRequest=[NSMutableURLRequest
requestWithURL:[NSURL URLWithString:@"http://username:[email protected]/statuses/update.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval: 60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[[NSString stringWithFormat:@"status=%", themessage] dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse* response;
NSError* error;
NSData* result = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
NSLog(@"%@", [[[NSString alloc] initWithData:result encoding:NSASCIIStringEncoding] autorelease]);
//END TWITTER BLACK MAGIC
它确实在一定程度上即代码运行,但你不能看到在Twitter上的结果 - 在resopnse我回来从Twitter在调试窗口是:
<request>/statuses/update.xml</request>
<error>Client must provide a 'status' parameter with a value.</error>
任何想法?
嗯,它真的很容易误读的OBJ-C,当你刚刚起步。谢谢,它现在一切正常! – Vidar 2009-11-21 22:44:54