2012-04-16 55 views
5

我已經通過郵寄方式發送該URL迴應:Instagram的API代碼爲400(錯誤請求)

https://api.instagram.com/v1/users/XXX/relationship?action=unfollow&access_token=YYY 

XXX是一個有效的用戶ID,我檢查了多次。令牌(YYY)也是正確的。

這是響應:

{"meta":{"error_type":"APIInvalidParametersError","code":400,"error_message":"please supply action=approve,ignore,follow,block,unblock,unfollow"}} 

我已經試過行動=遵循和行動=取消關注。這可能嗎,這是一個錯誤?我可以在哪裏報告?

Instagram的API文檔:http://instagram.com/developer/endpoints/relationships/

+0

您是否找到解決方案? – SuN 2015-03-04 07:04:05

+0

您是否找到解決方案? – MysticForce 2016-08-04 16:59:18

回答

7

的問題是,你是不是送行動POSTDATA。昨天我遇到了確切的問題。

該應的access_token在URL中發送,但行動=遵循應在要求的POSTDATA!

+0

的確,我也發現了它。謝謝。 – dislick 2012-04-19 07:06:32

+0

你如何指定它作爲postdata的一部分?我在ios上使用AF網絡,並將@ {「action」:@「follow」}字典作爲參數傳遞給我。 – nickthedude 2014-03-25 20:54:19

+0

@zolipapa我正在通過該行動=按照郵政體mutablerequest但沒有得到... 你如何解決這個問題? – 2014-06-04 07:06:51

1
NSString *initialURL = [NSString stringWithFormat:@"https://api.instagram.com/v1/users/USER_ID/relationship?access_token=ACCESS TOKEN"]; 
NSURL *url=[NSURL URLWithString:initialURL]; 

NSString *key = [NSString stringWithFormat:@"action=follow"]; 
NSData *mastData = [key dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; 
NSString *mastLength = [NSString stringWithFormat:@"%d",[mastData length]]; 

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; 
[request setURL:url]; 
[request setHTTPMethod:@"POST"]; 
[request setValue:mastLength forHTTPHeaderField:@"Content-Length"]; 
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; 
[request setHTTPBody:mastData]; 
NSURLConnection *con=[[NSURLConnection alloc]initWithRequest:request delegate:self]; 
[con start]; 
+0

你救了我的命!爲什麼他們不在文檔中提到這一點? – Curnelious 2014-09-11 15:20:19

0

此外,請確保在認證時使用適當的範圍。

在驗證URL添加scope=like+comments+relationships

相關問題