Instagram的API返回无效的用户ID [英] Instagram api returns invalid user id

查看:726
本文介绍了Instagram的API返回无效的用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的是Instagram的API获取用户ID为一个给定的Instagram的用户名(葡萄园)。此用户有52追随者。
https://instagram.com/vineyard

下面是API请求。用户ID是葡萄园。

<$p$p><$c$c>https://api.instagram.com/v1/users/search?q=vineyard&client_id={clientid}&count=1

API返回了以下信息


  

{\"meta\":{\"$c$c\":200},\"data\":[{\"username\":\"vineyardvines\",\"profile_picture\":\"https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/11910347_489504487878458_470147402_a.jpg\",\"id\":\"9210988\",\"full_name\":\"vineyard vines\"},{\"username\":\"vineyardphotography\",\"profile_picture\":\"https://igcdn-photos-b-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/11934830_1629418937331529_383082635_a.jpg\",\"id\":\"611786454\",\"full_name\":\"Martha's
  葡萄园}]}


下面的用户ID是另一个用户vineyardphotography谁拥有3920追随者的ID。这怎么可能。
有没有在我的API请求任何错误呢?


解决方案

搜索查询是通过限制为1 计数参数,我觉得搜索结果基于普及,媒体发布,和/或如下计数的。所以,这的对上述理论的prevents看到了希望用户名

要解决此删除数= 1

  https://api.instagram.com/v1/users/search?q=vineyard&client_id= {客户ID}

搜索的结果,而&LT;

然后你就可以通过数据环阵列和比较用户名字段针对目标用户名找到 ID

I am using the instagram api for getting the user id for a given instagram user name(vineyard). This user has 52 followers. https://instagram.com/vineyard

Here is the api request. User ID is vineyard.

https://api.instagram.com/v1/users/search?q=vineyard&client_id={clientid}&count=1

The api returns the following information

{"meta":{"code":200},"data":[{"username":"vineyardvines","profile_picture":"https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/11910347_489504487878458_470147402_a.jpg","id":"9210988","full_name":"vineyard vines"},{"username":"vineyardphotography","profile_picture":"https://igcdn-photos-b-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/11934830_1629418937331529_383082635_a.jpg","id":"611786454","full_name":"Martha's Vineyard"}]}

Here the userid is the id of another user "vineyardphotography" who has 3920 followers. How is it possible. Is there any mistake in my api request ?

解决方案

The search query is limited to 1 through count parameter, and I think the search results are based on popularity, media posted, and/or follows counts. So, this for above theory prevents seeing the wanted username.

To resolve this remove count=1

https://api.instagram.com/v1/users/search?q=vineyard&client_id={client-id}

Then you can loop through data array and compare username field against target username to find the id

这篇关于Instagram的API返回无效的用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆