5

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...

2 Answers 2

4

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."

0
4

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
    
2
  • 1
    Javascript unfollows few users, scrolls down to show another users and after 10 minutes again.
    – Dudem
    Nov 29, 2018 at 11:15
  • 1
    I think it works, thanks for sharing! Nov 4, 2021 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.