更新MGTwitterEngine新Twitter的API 1.1版(Updating MGTwit

2019-10-18 06:41发布

我目前正在更新我的应用程序从XML到以.json为Twitter的新的API V1.1。 我公司目前已上传.json工作,可以登录,让我的时间表,提到了,但试图获得直接的信息,列表,或用户信息时,似乎它寻找“曲奇”,但它没有存储。

这是试图做一个简单的GET用户/显示呼叫时由Twitter收到错误消息:

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]; 是;是,如果我检查我的访问令牌字符串,我得到了什么存储在初始登录。 我已经搜查,搜查,以正在发生什么或如何解决这些问题,但我只是被卡住,任何帮助,将不胜感激。

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

Answer 1:

参考FHSTwitterEngine你可以使用新的和FHSTwitterEngine如果你要求这个方法没有autenticating,用户状态被删除......你需要发送方键值而且随着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;
}


文章来源: Updating MGTwitterEngine to New Twitter API v1.1