1

我目前正在将我的应用程序从 xml 更新为 .json,用于 Twitter 的新 API v1.1。我目前有 .json 工作并且可以登录、获取我的时间线、提及,但是当尝试获取直接消息、列表或用户信息时,它似乎在寻找“cookies”但它没有被存储。

这是 twitter 在尝试进行简单的 GET user/show 调用时收到的错误消息:

Twitter request failed: 08AD12D3-0044-49AB-8D3D-4E61D8398550 with error:Error Domain=HTTP 
 Code=400 "The operation couldn’t be completed. (HTTP error 400.)" UserInfo=0xce90540  
{response=<NSHTTPURLResponse: 0xce94bd0> { URL: 
https://api.twitter.com/1.1/users/show.json?screen_name=FreeAppl3 } { status code: 400,  
headers {
"Content-Encoding" = gzip;
"Content-Type" = "application/json; charset=utf-8";
Date = "Fri, 14 Jun 2013 09:25:40 UTC";
Server = tfe;
"Set-Cookie" = "guest_id=v1%3A137120194019582695; Domain=.twitter.com; Path=/; 
Expires=Sun, 14-Jun-2015 09:25:40 UTC";
"Strict-Transport-Security" = "max-age=631138519";
"Transfer-Encoding" = Identity;

} }, body={"errors":[{"message":"Bad Authentication data","code":215}]}hjD4nzoeOUaTQ1Q%3D}

当我调用 [twitterEngine isAuthorized]; 返回 YES,如果我检查我的访问令牌字符串,我会收到初始登录时存储的内容。我已经搜索并搜索了正在发生的事情或如何解决问题,但我只是卡住了,任何帮助将不胜感激。

Twitter API - https://dev.twitter.com/docs/api/1.1/get/users/show Twitter 错误代码 - https://dev.twitter.com/docs/error-codes-responses

4

1 回答 1

2

参考 FHSTwitterEngine您可以使用新的 FHSTwitterEngine 如果您请求此方法而不进行身份验证,则用户状态将被删除......您需要发送消费者密钥和令牌以及 screen_name..

在 FHSTwitterEngine

//get username pass to method. In Dictionary you can get all info  
NSString *username = [[FHSTwitterEngine sharedEngine]loggedInUsername];
NSDictionary *data=[[FHSTwitterEngine sharedEngine]getUserProfile:username];


 // method to get all user info
-(id)getUserProfile:(NSString *)username
{

   if (username.length == 0) {
      return getBadRequestError();
   }

   NSURL *baseURL = [NSURL URLWithString:url_users_show];
   OAMutableURLRequest *request = [OAMutableURLRequest requestWithURL:baseURL consumer:self.consumer token:self.accessToken];
   OARequestParameter *usernameP = [OARequestParameter requestParameterWithName:@"screen_name" value:username];

   NSArray *params = [NSArray arrayWithObjects:usernameP, nil];

   id userShowReturn = [self sendGETRequest:request withParameters:params];
   return userShowReturn;
}
于 2013-06-14T11:49:35.283 回答