【问题标题】:Instagram API responds with code 400 (Bad Request)Instagram API 响应代码 400(错误请求)
【发布时间】:2012-04-16 09:51:25
【问题描述】:

我已经通过帖子发送了这个网址:

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/

【问题讨论】:

  • 你找到解决办法了吗?
  • 你找到解决办法了吗?

标签: api instagram


【解决方案1】:

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

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

【讨论】:

  • 没错,我也发现了。谢谢。
  • 如何将其指定为 postdata 的一部分?我在 ios 上使用 AF 网络并将 @{"action" : @"follow"} 字典作为参数传递。
  • @zolipapa 我在 mutablerequest 的 Post 正文中传递了 action=follow 但一无所获......你如何解决这个问题?
  • 你找到解决办法了吗?
【解决方案2】:
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];

【讨论】:

    【解决方案3】:

    还要确保在进行身份验证时使用正确的范围。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-17
      • 1970-01-01
      • 1970-01-01
      • 2023-01-28
      • 2021-01-07
      相关资源
      最近更新 更多