简体   繁体   中英

Instagram API Likes Javascript

Ok so I have been trying for the last two hours to get a like on an image... I use this call:

$.ajax({
   method: "POST",
   url: 'https://api.instagram.com/v1/media/'+$media_id+'/likes?access_token='+$access_token,
   dataType: "jsonp",
   jsonp: "callback",
   jsonpCallback: "jsonpcallback",
   success: function(data) {
       console.log(data);
       alert('success liked');
   },
   error: function(jqXHR, textStatus, errorThrown) {
       alert( "Feed Error! jqXHR: " + jqXHR + " textStatus: " + textStatus + " errorThrown: " + errorThrown );
   }
});

But for some reason it's not giving me a like rather just the list of likers?

On the documentation it uses the curl method for posting a like, however I need a javascript/jquery solution?

Any help would greatly be appreciated!

Thanks a mil!

you have to specify type:"POST" not method:"POST"

Since there is no type specified, it is doing a GET call and so it is getting list of likes :)

(btw POST may not work because of Cross-Origin Access, give it a shot)

Thanks for the help.

This question has been resolved.

Instagram doesn't allow JSONP requests :)

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