well i'll be god damned. after many wasted hours on this, here was the issue. i'll actually note it here instead of letting this unanswered like so many other -1012 errors on the interwebs.
My code was just fine... the account I was testing with only had read- only access back from when my twitter api access was first set up. I had to go in and remove access to the app on twitter.com and then everything worked... time for a drink. On Aug 23, 12:34 pm, "s.w." <[email protected]> wrote: > So.. I'm using OAuthConsumer, and I've already written code in the > past to successfully POST requests to foursquare to get tokens and to > check in. I'm using the same code to now integrate with twitter and am > running into issues. I can successfully get a token, but when I make > signed POST requests I end up with an error. > > I changed the value for my key and token below for security reasons in > making this post: > > 2010-08-23 12:23:06.865 App[18006:207] signature base string: POST&http > %3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.xml&lat > %3D40.4283%26long%3D-79.9717%26oauth_consumer_key > %3DN24e2mycZtstsHiW0zuYg%26oauth_nonce > %3D09220CB8-29BB-4C70-9A58-470323D1AD1C%26oauth_signature_method > %3DHMAC-SHA1%26oauth_timestamp%3D1282580586%26oauth_token%3D20594114- > P49fHNYzANBUuHjfTELKUBrNi5lsdgCygJzlw2dBo%26oauth_version > %3D1.0%26status%3Dtest > > 2010-08-23 12:23:06.865 Beerby[18006:207] oauth header: OAuth > realm="", oauth_consumer_key="N24e1my4ZtstgHiW0z2Yg", > oauth_token="20594114-P49fHNYzANBUuHjfTELKUBrNi5lsdgCygJzlw2dBo", > oauth_signature_method="HMAC-SHA1", oauth_signature="XxBW54PfcqsePoe6c > %2BnYupz8UE4%3D", oauth_timestamp="1282580586", > oauth_nonce="09220CB8-29BB-4C70-9A58-470323D1AD1C", > oauth_version="1.0" > > 2010-08-23 12:23:16.006 Beerby[18006:207] statusRequest error:Error > Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be > completed. (NSURLErrorDomain error -1012.)" UserInfo=0xec06ec0 > {NSErrorFailingURLKey=http://api.twitter.com/1/statuses/update.xml, > NSErrorFailingURLStringKey=http://api.twitter.com/1/statuses/ > update.xml, NSUnderlyingError=0xec036a0 "The operation couldn’t be > completed. > > Here's the code I'm using when making my request > > OAMutableURLRequest *request; > OADataFetcher *fetcher; > NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/ > statuses/update.xml"]; > //NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/ > users/lookup.xml"]; > > request = [[[OAMutableURLRequest alloc] initWithURL:url > > consumer:self.consumer > > token:self.accessToken > realm:nil > signatureProvider:nil] > autorelease]; > > [request setHTTPMethod:@"POST"]; > > NSString *s = [NSString stringWithString:@"test"]; > > NSString *status = [s precomposedStringWithCanonicalMapping]; > NSLog(@"twitter status %@", status); > > OARequestParameter *x1 = [[OARequestParameter alloc] > initWithName:@"status" value:status]; > OARequestParameter *x2 = [[OARequestParameter alloc] > initWithName:@"lat" value:[NSString stringWithFormat:@"%g",geolat]]; > OARequestParameter *x3 = [[OARequestParameter alloc] > initWithName:@"long" value:[NSString > stringWithFormat:@"%g",geolong]]; > > NSArray *params = [NSArray arrayWithObjects:x1,x2,x3,nil]; > [request setParameters:params]; > > fetcher = [[[OADataFetcher alloc] init] autorelease]; > [UIApplication > sharedApplication].networkActivityIndicatorVisible = > YES; > [fetcher fetchDataWithRequest:request > delegate:self > > didFinishSelector:@selector(statusRequest:didFinishWithData:) > > didFailSelector:@selector(statusRequest:didFailWithError:)]; > > [x1 release]; > [x2 release]; > [x3 release]; > > For further information, I can successfully send signed GET requests. > Also, for methods that can use GET or POST, GET works just fine, but > POST throws the same old error. Any help would be greatly appreciated.
