【问题标题】:GTM OAuth Twitter update errorGTM OAuth Twitter 更新错误
【发布时间】:2012-01-27 03:57:14
【问题描述】:

我在使用 gtm oauth 工具箱时遇到了发布问题。我一直在尝试向 Twitter 发送推文,但我不断收到授权错误。现在我收到以下错误,代码如下“POST错误:错误域=com.google.HTTPStatus代码=401”操作无法完成。 (com.google.HTTPStatus 错误 401。)”

NSString *body = [NSString stringWithFormat: @"status=thisisatest"]; 
NSString *urlStr = @"http://api.twitter.com/1/statuses/update.json"; 
NSURL *url = [NSURL URLWithString:urlStr]; 
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 
[request setHTTPMethod:@"POST"]; 
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; 
[request setHTTPBody: [body dataUsingEncoding:NSUTF8StringEncoding]]; 
GTMHTTPFetcher* myFetcher = [GTMHTTPFetcher 
                             fetcherWithRequest:request]; 
[myFetcher setAuthorizer: mAuth]; 
[myFetcher beginFetchWithCompletionHandler:^(NSData *retrievedData, 
                                             NSError *error) 
 { 
     if (error != nil) 
     { 
         NSLog(@"POST error: %@", error); 
     } 
     else 
     { 
         NSDictionary *results = [[[[NSString alloc] initWithData: 
                                    retrievedData encoding:NSUTF8StringEncoding] autorelease] JSONValue]; 
         NSLog(@"POST Successful: #%@ @ %@", [results objectForKey: 
                                              @"id"], [results objectForKey: @"created_at"]); 
     } 
 }]; 

我在这里做错了什么?令牌已存储在钥匙串中。我需要检索钥匙串令牌还是 gtm 自动签署请求?

【问题讨论】:

    标签: objective-c cocoa oauth nsurlconnection google-toolbox-for-mac


    【解决方案1】:

    好的,我发现了问题。我错过了消费者密钥的 GTM .m 文件中的一个位置。这就是我急于求成的结果。 :-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-16
      • 2014-06-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-06
      • 2014-02-11
      • 2012-01-01
      相关资源
      最近更新 更多