Updating MGTwitterEngine to New Twitter API v1.1

爱⌒轻易说出口 提交于 2020-01-25 03:37:06

问题


I am currently updating my app to .json from xml for Twitters new API v1.1. I currently have .json working and can log on, get me timelines, mentions, but when trying to get direct messages, lists, or user info it seems its looking for "cookies" but it is not stored.

This is the error message received by twitter when trying to make a simple GET user/show call:

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}

When I call [twitterEngine isAuthorized]; is returns YES and if I check for my access token string, I receive what was stored on initial login. I have searched and searched as to what is happening or how to fix the issues, but am simply stuck and any help would be greatly appreciated.

Twitter API - https://dev.twitter.com/docs/api/1.1/get/users/show Twitter Error Codes - https://dev.twitter.com/docs/error-codes-responses


回答1:


refer FHSTwitterEngine you can use newly FHSTwitterEngine and if you request this method without autenticating, the users status is removed... you need to send consumer key and token along with screen_name..

In 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;
}


来源:https://stackoverflow.com/questions/17103831/updating-mgtwitterengine-to-new-twitter-api-v1-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!