簡體   English   中英

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

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

目前,我正在將我的應用程序從xml更新為Twitters新API v1.1的.json。 我目前可以使用.json進行工作,並且可以登錄,獲得時間表,提及我,但是當嘗試獲取直接消息,列表或用戶信息時,它似乎在尋找“ cookies”,但未存儲。

這是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}

當我打電話給[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

請參考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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM