Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to do Instagram user Follow and Unfollow from my site. I am using Instagram API+ codeignator to do this. In front end, i am listing instagram users with a "Follow" & "Following" button. 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...

like image 919
Sinto Avatar asked Jul 28 '15 12:07

Sinto


2 Answers

Instagram now requires that you request special permission from them in order to follow users using their API. So you will not be able to follow/unfollow a user with the API until Instagram grants you these permissions.

Here is where you request access: 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."

like image 191
Bill Rollins Avatar answered Oct 31 '22 17:10

Bill Rollins


Unfollow Instagram users using browser console:

  1. Open Instagram in browser on PC
  2. Go to your account
  3. Show following users
  4. Open developer tools (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
    
like image 20
Dudem Avatar answered Oct 31 '22 17:10

Dudem