亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

知道 Instagram 用戶名我可以只使用 API 關注用戶嗎?

知道 Instagram 用戶名我可以只使用 API 關注用戶嗎?

PHP
慕斯709654 2021-12-24 09:40:04
這個問題問了很多,但最后更新的答案是 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());}
查看完整描述

1 回答

?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

我剛剛發現如何做到這一點。如果您知道用戶名,則必須首先使用以下代碼找到 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());

}


查看完整回答
反對 回復 2021-12-24
  • 1 回答
  • 0 關注
  • 192 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號