Instagram API以代码400(错误请求)响应

时间:2012-04-16 09:51:25

标签: api instagram

我已通过帖子发送此网址:

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"}}

我尝试过action = follow和action = unfollow。有可能,这是一个错误吗?我在哪里可以举报?

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

3 个答案:

答案 0 :(得分:8)

问题是您没有将操作作为postdata发送。我昨天遇到了确切的问题。

access_token应该在url中发送,但action = follow应该在请求的postdata中!

答案 1 :(得分: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];

答案 2 :(得分:0)

同时确保在验证时使用适当的范围。

在该身份验证网址中添加scope=like+comments+relationships