知道 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 用户名的用户,例如这个用户名- girlinred.band
我看到有取消关注的代码,但是我找不到下面的:
/**
* 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());
}
这个问题被问了很多,但最后更新的答案是 3-4 年前。我想知道我是否能够使用 mgp25 (https://github.com/mgp25/Instagram-API) 制作的 Instagram 的 PHP API 并在我的商业 Instagram 帐户上关注一个知道他的 Instagram 用户名的用户,例如这个用户名- girlinred.band
我看到有取消关注的代码,但是我找不到下面的:
/**
* 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());
}