简体   繁体   中英

Instagram API: Follow Issue

I am trying to use the Instagram API to follow an array of users (via their id's). I am using the last endpoint documented here: http://instagram.com/developer/endpoints/relationships/ . After sending the request, I receive some data back (code: 200, incoming_status:"none", outgoing_status:"none").

Here is the code snippet (javascript with jQuery):

var access_parameters = {action:"follow"};
for (key in users) {
   if (users.hasOwnProperty(key)) {
      var username = key;
      var instagramUrl = "https://api.instagram.com/v1/users/"+users[key][0]+"/relationship?access_token=[ACCESS_TOKEN]"; //where users[key][0] is the id of the user intended to follow and [ACCESS_TOKEN] is my access token
      $.ajax({
         type:"POST",
         async: false,
         dataType: 'jsonp',
         url: instagramUrl,
         contentType: 'text/plain; charset=UTF-8',
         data: access_parameters
      }).done(function ( data ) {
         if( console && console.log ) {
            console.log(data); //this is where the above data comes through
         }
      });
   }
}

I have tried a few permutations of putting the access_token in the data array and in the url, also the same with the action="follow". It seems like the endpoint is not receiving the action parameter and is simply returning the status of the current relationship.

I had the same error. If you take a look at the Network call from the Developers Toolbar, I bet you're making a GET request for the user relationship, and the server is returning that data.

You need to supply one of //action={follow,unfollow,block,unblock,approve,deny}.

I am reading a lot of client side CORS issues for POST requests, especially for the relationship POST.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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