![](/img/trans.png)
[英]How can I follow & unfollow Instagram users using the instagram API
[英]Knowing Instagram username can I follow a user using only the API?
這個問題被問了很多,但是最后更新的答案是3-4年前。 我想知道我是否能夠使用由mgp25( https://github.com/mgp25/Instagram-API )制造的Instagram的PHP API,並在我的商業Instagram帳戶上關注一個用戶,知道他的Instagram用戶名,例如該用戶名-女孩樂隊
我看到有不遵循的代碼,但是找不到以下代碼:
/**
* Remove one of your followers.
*
* @param string $userId Numerical UserPK ID.
*
* @throws \InstagramAPI\Exception\InstagramException
*
* @return \InstagramAPI\Response\FriendshipResponse
*/
public function removeFollower(
$userId)
{
return $this->ig->request("friendships/remove_follower/{$userId}/")
->addPost('_uuid', $this->ig->uuid)
->addPost('_uid', $this->ig->account_id)
->addPost('_csrftoken', $this->ig->client->getToken())
->addPost('user_id', $userId)
->addPost('radio_type', 'wifi-none')
->getResponse(new Response\FriendshipResponse());
}
我只是發現如何做到。 如果您知道用戶名,則必須先找到具有以下代碼的Instagram ID(數字):
$id = $ig->people->getUserIdForName('girlinred.band');
然后,當您擁有ID時,您可以簡單地運行以下代碼來關注成員
$ig->people->follow($id);
如果需要,這里是從API本身獲取的完整方法:
/**
* Follow a user.
*
* @param string $userId Numerical UserPK ID.
*
* @throws \InstagramAPI\Exception\InstagramException
*
* @return \InstagramAPI\Response\FriendshipResponse
*/
public function follow(
$userId)
{
return $this->ig->request("friendships/create/{$userId}/")
->addPost('_uuid', $this->ig->uuid)
->addPost('_uid', $this->ig->account_id)
->addPost('_csrftoken', $this->ig->client->getToken())
->addPost('user_id', $userId)
->addPost('radio_type', 'wifi-none')
->getResponse(new Response\FriendshipResponse());
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.