Twitter oauth problem with frindship/create in api

2019-08-18 02:11发布

问题:

I am using Google Data API sample touch application, which is available at code.google....

I am having a problem can any one help.

Please tell me if I am doing some thing wrong.

The user who has loged in has to follow some person XYZ (just using XYZ for security purpose).

I am using the URL

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);
       }

In the response I get

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

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

回答1:

This error can happen if your time and the server time are more than 5 mins different, check that your server / pc has the same time as the server.