Instagram的API返回无效的用户ID [英] Instagram api returns invalid user 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=1API返回了以下信息
{\"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}
然后你就可以通过
数据环
阵列和比较用户名
字段针对目标用户名找到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 wantedusername
.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 compareusername
field against target username to find theid
这篇关于Instagram的API返回无效的用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!