title: How can I follow & unfollow Instagram users using the instagram API
body: <p>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" &amp; "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:</p>
  
  <pre><code>$follow_id =$_POST['id'];
  $accessToken = @$this-&gt;session-&gt;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-&gt;meta-&gt;code;
  $errorMsg = $resultObj-&gt;meta-&gt;error_message;
  </code></pre>
  
  <p>As a response to this, I am getting an "Internal Server error".
  Is this code fine for my requirement.
  Waiting for your answers...</p>