简体   繁体   English

如何使用 Instagram API 关注和取消关注 Instagram 用户

[英]How can I follow & unfollow Instagram users using the instagram API

I am trying to do Instagram user Follow and Unfollow from my site.我正在尝试从我的网站上关注和取消关注 Instagram 用户。 I am using Instagram API+ codeignator to do this.我正在使用 Instagram API+ codeignator 来做到这一点。 In front end, i am listing instagram users with a "Follow" & "Following" button.在前端,我列出了带有“关注”和“关注”按钮的 Instagram 用户。 When user is following and they click on "Following" it should "Unfollow" user.当用户关注并点击“关注”时,它应该“取消关注”用户。 When button shows "Follow" and user clicks on it, the button should change to following and start following user.当按钮显示“关注”并且用户单击它时,按钮应更改为关注并开始关注用户。 I am adding code that i did:我正在添加我所做的代码:

$follow_id =$_POST['id'];
$accessToken = @$this->session->userdata('instagram_accessTokeninst');
$url= 'https://api.instagram.com/v1/users/'.$follow_id.'/relationship?access_token='.$accessToken;
$data = 'action=follow';
$resultObj = json_decode(sendPostData($url,$data));
print_r($resultObj);
$responseCode = $resultObj->meta->code;
$errorMsg = $resultObj->meta->error_message;

As a response to this, I am getting an "Internal Server error".作为对此的回应,我收到了“内部服务器错误”。 Is this code fine for my requirement.这段代码适合我的要求吗? Waiting for your answers...等待你的答案...

Instagram now requires that you request special permission from them in order to follow users using their API. Instagram 现在要求您向他们请求特殊许可,以便使用他们的 API 关注用户。 So you will not be able to follow/unfollow a user with the API until Instagram grants you these permissions.因此,在 Instagram 授予您这些权限之前,您将无法使用 API 关注/取消关注用户。

Here is where you request access: https://help.instagram.com/contact/185819881608116这是您请求访问的地方: https : //help.instagram.com/contact/185819881608116

FYI, here are guidelines from Instagram about requesting these permissions: "The ability to POST and DELETE likes, follows and comments is restricted to applications that offer business services and not consumer facing apps."仅供参考,以下是 Instagram 关于请求这些权限的指导方针:“发布和删除喜欢、关注和评论的能力仅限于提供商业服务的应用程序,而不是面向消费者的应用程序。”

Unfollow Instagram users using browser console:使用浏览器控制台取消关注 Instagram 用户:

  1. Open Instagram in browser on PC在 PC 上的浏览​​器中打开 Instagram
  2. Go to your account转到您的帐户
  3. Show following users显示以下用户
  4. Open developer tools (F12)打开开发人员工具 (F12)
  5. Go to console tab转到控制台选项卡
  6. Enter this code:输入此代码:

     setInterval( function(){ var arr = document.getElementsByClassName("_0mzm- sqdOP L3NKy _8A5w5 "); for (var i = 1, len = arr.length; i < len; i++) { arr[i].click(); document.getElementsByClassName("aOOlW -Cab_ ")[0].click(); } var scroll_stuff = document.getElementsByClassName("isgrP")[0]; scroll_stuff.scrollTop = scroll_stuff.scrollHeight; } , 600000); //every 10 minutes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM