Twitter oauth问题与frindship /在api中创建

时间:2010-06-11 10:25:52

标签: iphone objective-c oauth twitter google-data-api

我正在使用Google Data API示例触摸应用程序,该应用程序可在code.google ....

上找到

我遇到问题可以帮助。

如果我做错了,请告诉我。

已经进入的用户必须关注某人XYZ(仅使用 XYZ用于安全目的)。

我正在使用网址

urlStr = @"http://api.twitter.com/1/friendships/create/XYZ.xml";

NSURL *url = [NSURL URLWithString:urlStr];

       NSMutableURLRequest *request = [NSMutableURLRequest
requestWithURL:url];


//made post as requested in twitter API

       [request setHTTPMethod:@"POST"];

       ConnectAppDelegate *appDelegate = (ConnectAppDelegate *)
[[UIApplication sharedApplication] delegate];

       [mAouth authorizeRequest:request];
NSError *error = nil;
       NSURLResponse *response = nil;
       NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
       if (data) {
               // API fetch succeeded
               NSString *str = [[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding] autorelease];
               NSLog(@"API response: %@", str);
       } else {
               // fetch failed
               NSLog(@"API fetch error: %@", error);
       }

在我得到的回复中

http://api.twitter.com/1/friendships/create/XYZ.xml 2010-06-11 16:04:39.437连接[4265:20b] API响应:

<?xml
version="1.0" encoding="UTF-8"?>
<hash>
 <request>/1/friendships/create/XYZ.xml</request>
 <error>Invalid / used nonce</error>
</hash>

1 个答案:

答案 0 :(得分:0)

如果您的时间和服务器时间超过5分钟,则会发生此错误,请检查您的服务器/ PC与服务器的时间是否相同。