iOS Twitter SLRequest returning url domain error -1012

kbegeman
@kbegeman Kyle Begeman

I am attempting to perform reverse oauth to get twitter access tokens for a server.

I have figured out how to submit the request and receive a response, but when I do, it gives me this error:

Error: The operation couldn’t be completed. (NSURLErrorDomain error -1012.)

I looked this up, and it says that it means the user has canceled the request. I am not sure how this is possible, and I cannot figure out how to fix it.

Here is my code:

  1.     NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
  2.     NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp];
  3.  
  4.     NSString *oauth_nonce = [self genRandStringLength:32];
  5.     NSString *oauth_timestamp = [timeStampObj stringValue];
  6.  
  7.     NSURL *feedURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/request_token"];
  8.  
  9.     NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys: @"my key here", @"oauth_consumer_key", oauth_nonce, @"oauth_nonce", @"HMAC-SHA1", @"oauth_signature_method", oauth_timestamp, @"oauth_timestamp", @"1.0", @"oauth_version", @"reverse_auth", @"x_auth_mode", nil];
  10.  
  11.     SLRequest *twitterFeed = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:feedURL parameters:parameters];
  12.  
  13.     twitterFeed.account = self.userAccount;
  14.  
  15.  
  16.     // Making the request
  17.  
  18.     [twitterFeed performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
  19.         dispatch_async(dispatch_get_main_queue(), ^{
  20.  
  21.             // Check if we reached the reate limit
  22.  
  23.             if ([urlResponse statusCode] == 429) {
  24.                 NSLog(@"Rate limit reached");
  25.                 return;
  26.             }
  27.  
  28.             // Check if there was an error
  29.  
  30.             if (error) {
  31.                 NSLog(@"The Error is: %@", error.localizedDescription);
  32.                 return;
  33.             }
  34.  
  35.             // Check if there is some response data
  36.             if (responseData) {
  37.  
  38.                 NSLog(@"%@", responseData);
  39.  
  40.             }
  41.         });
  42.     }];

There must be something simple I am missing, and this is keeping me from finishing a project. Any help would be great, thanks!

40 weeks 2 days ago