无法验证您的身份

时间:2011-03-19 11:21:34

标签: iphone twitter

消息下的

是我的代码。但我收到错误消息“无法验证您”

我该如何解决?

谢谢

- (IBAction) sendButtonTapped: (id) sender {
    NSString* themessage = [NSString stringWithFormat:@" %@. I'm %@ and feeling %@ about it.",
                            notesField.text ? notesField.text :@"", 
                            [activities objectAtIndex:[tweetPicker selectedRowInComponent:0]],
                            [feelings objectAtIndex:[tweetPicker selectedRowInComponent:1]]];
    NSLog(@"Twett buttone tapped ");

    //TWITTER BLACK MAGIC
    NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://user name:password@twitter.com/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

}

1 个答案:

答案 0 :(得分:0)

要调用Twitter Web服务API,您必须使用OAuth,请阅读here