【问题标题】:Instagram API just can't follow userInstagram API 无法关注用户
【发布时间】:2014-09-11 13:37:27
【问题描述】:

我尝试了任何方法,但我无法关注用户。我从移动设备发出这个请求,使用:

https://api.instagram.com/v1/users/29440194/relationship?access_token=myValideToken&action=follow

我一直在获得状态:

{"meta":{"code":200},"data":{"outgoing_status":"none","target_user_is_private":false,"incoming_status":"none"}}

我必须在哪里获得传出状态:requested

我可以看到一些关于他们的 api 的东西,你不能从客户端发出 post 请求,这是我无法理解的。我们有一个 iPhone 应用程序必须发出该帖子请求,还有其他方法吗?

我们设法用同样的令牌得到了用户的时间线。

编辑: 我们还将 usee 令牌的范围设置为具有“关系”,但我们只是一次又一次地得到相同的响应。只是无法关注任何人,也没有他们的支持。

//ios
        NSString *follow=[NSString stringWithFormat:@"https://api.instagram.com/v1/users/%@/relationship?access_token=%@&action=follow",userID, token];
        NSLog(@"%@",follow);
          NSURL *url = [NSURL URLWithString:follow];
         NSData *data = [NSData dataWithContentsOfURL:url];
         NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
         NSLog(@"answer=%@", ret);

【问题讨论】:

  • 这太疯狂了,我们什么都试过了。我从来没有遇到过这种问题,我们只是无法继续开发。他们的 API 似乎如此未完成。没有人可以和你说话。我们完全迷失了。

标签: objective-c api instagram


【解决方案1】:

我已经设法解决了:

NSString *initialURL = [NSString stringWithFormat:@"https://api.instagram.com/v1/users/%@/relationship?access_token=%@",userID,token];
NSURL *url=[NSURL URLWithString:initialURL];

NSString *key = [NSString stringWithFormat:@"action=follow"];
NSData *mastData = [key dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *mastLength = [NSString stringWithFormat:@"%lu",(unsigned long)[mastData length]];

NSMutableURLRequest *request =  [[NSMutableURLRequest alloc] init]  ;
[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];

我只是想不通为什么 instagram 不让你知道你必须在请求值中添加操作。

【讨论】:

    猜你喜欢
    • 2015-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-15
    • 1970-01-01
    • 2014-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多