Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 1.19 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. GTM OAuth Twitter update error
  2. NSString *body = [NSString stringWithFormat: @"status=thisisatest"];
  3. NSString *urlStr = @"http://api.twitter.com/1/statuses/update.json";
  4. NSURL *url = [NSURL URLWithString:urlStr];
  5. NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  6. [request setHTTPMethod:@"POST"];
  7. [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  8. [request setHTTPBody: [body dataUsingEncoding:NSUTF8StringEncoding]];
  9. GTMHTTPFetcher* myFetcher = [GTMHTTPFetcher
  10.                              fetcherWithRequest:request];
  11. [myFetcher setAuthorizer: mAuth];
  12. [myFetcher beginFetchWithCompletionHandler:^(NSData *retrievedData,
  13.                                              NSError *error)
  14.  {
  15.      if (error != nil)
  16.      {
  17.          NSLog(@"POST error: %@", error);
  18.      }
  19.      else
  20.      {
  21.          NSDictionary *results = [[[[NSString alloc] initWithData:
  22.                                     retrievedData encoding:NSUTF8StringEncoding] autorelease] JSONValue];
  23.          NSLog(@"POST Successful: #%@ @ %@", [results objectForKey:
  24.                                               @"id"], [results objectForKey: @"created_at"]);
  25.      }
  26.  }];