This question is asked a lot, but last updated answer is from 3-4 years ago. I want to know if I am able to use the PHP API of Instagram made by mgp25 ( https://github.com/mgp25/Instagram-API ) and follow a user on my business Instagram account knowing his Instagram username for example this username - girlinred.band
I saw there is unfollow code, but I can't find the follow one:
/**
* 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());
}
I just found how it could be done. If you know the username you have to find first the Instagram ID (numbers) with this code:
$id = $ig->people->getUserIdForName('girlinred.band');
then when you have the ID you can simple run this code to follow a member
$ig->people->follow($id);
and here is the full method taken from the API itself in case you need it:
/**
* 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());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.