简体   繁体   English

将MGTwitterEngine更新到新的Twitter API v1.1

[英]Updating MGTwitterEngine to New Twitter API v1.1

I am currently updating my app to .json from xml for Twitters new API v1.1. 目前,我正在将我的应用程序从xml更新为Twitters新API v1.1的.json。 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. 我目前可以使用.json进行工作,并且可以登录,获得时间表,提及我,但是当尝试获取直接消息,列表或用户信息时,它似乎在寻找“ cookies”,但未存储。

This is the error message received by twitter when trying to make a simple GET user/show call: 这是twitter在尝试进行简单的GET用户/显示调用时收到的错误消息:

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]; 当我打电话给[twitterEngine isAuthorized]时; is returns YES and if I check for my access token string, I receive what was stored on initial login. 是返回YES,并且如果我检查访问令牌字符串,则收到初始登录时存储的内容。 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 Twitter API- https://dev.twitter.com/docs/api/1.1/get/users/show Twitter错误代码-https: //dev.twitter.com/docs/error-codes-responses

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.. 请参考FHSTwitterEngine,您可以重新使用FHSTwitterEngine,如果您不要求注意就请求此方法,则将删除用户状态...您需要将使用者密钥和令牌以及screen_name一起发送。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM