简体   繁体   中英

Like Instagram Photo with AJAX

I'm trying to create an Instagram feed on my site that not only shows pictures from my feed but also allows them to comment and like my photos as well. I have worked with the Instagram API to get to a point where I can do all of those things but they have to happen on the server side (I'm running PHP), thus the page has to be refreshed when they click the like button and I'm hoping to avoid that. I've tried to create an AJAX POST request based on the Instagram API but I can't seem to get it to work. It is returning a JSON of the likes for that particular photo rather than adding a like from my account. If anybody has had any experience with this in the past I would really appreciate any advice.

Thanks

Here is what I have:

$.ajax({
type: "POST",
dataType: "jsonp",
url: "https://api.instagram.com/v1/media/MEDIA_ID/likes?access_token=ACCESS_TOKEN",
success: function(data) {}});

Found the answer here, How to post like with ajax to instagram? Help me please

Make sure your dataType is json not jsonp.

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