使用 Instagram 获取特定用户名数据 API

Get the specific username data with Instagram API

我正在尝试使用 Instagram API 从确切或特定的用户名搜索并获取数据(个人资料图片和用户名)。问题是如果我搜索例如 starwars 它不会显示官方页面,它会显示这个用户名:starwars_viii !!!这是我的代码:

https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]&count=1

我不得不说我在未经身份验证的情况下获取数据。

您确定仅提供客户 ID 就足够了吗?根据 their docs,你应该提供一个 access_token:

https://api.instagram.com/v1/users/search?q=jack&access_token=ACCESS-TOKEN

回复:

{
    "data": [{
        "username": "jack",
        "first_name": "Jack",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_66_75sq.jpg",
        "id": "66",
        "last_name": "Dorsey"
    },
    {
        "username": "sammyjack",
        "first_name": "Sammy",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_29648_75sq_1294520029.jpg",
        "id": "29648",
        "last_name": "Jack"
    },
    {
        "username": "jacktiddy",
        "first_name": "Jack",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_13096_75sq_1286441317.jpg",
        "id": "13096",
        "last_name": "Tiddy"
    }]
}

正如您在响应中看到的那样,第一个结果是准确的用户名 "jack"。

我通过 count = 10 解决了这个问题,然后用确切的用户名过滤它