这个问题被问了很多,但最后更新的答案是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());
}
答案 0 :(得分:0)
我刚刚发现可以怎么做。如果您知道用户名,则必须先找到具有以下代码的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());
}