hi all could any one tell me how i can post a like and delete an instagram like using api? i tried to delete a like using this code but i dont get any response from ajax call. could any one tell me what i am doing wrong here ?is this possible doing php ?how?
xxxxxxxxxxxxxxxxxx_xxxxxxxx ==> Media-Id such as: 23424343243243_2343243243
Instagram API Docs for Deleting Like
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
function deleteLike() {
alert("inside function");
var url = "https://api.instagram.com/v1/media/xxxxxxxxxxxxxxxxxx_xxxxxxxx/likes?access_token=XXXX";
$.post(url, {
"method": "delete",
}, function(data)
{
var ajaxResponse = data;
alert("success"+ajaxResponse);
})
}
</script>
</head>
<body onload="deleteLike();">
</html>
Edited:cross domain php curl:(but how to tell it if this is post method or delete method?"
$url = "https://api.instagram.com/v1/media/xxxxxxxxxxxxxxxxxx_xxxxxxxx/likes?access_token=XXXX";
$api_response = get_data(''.$url);
$record = json_decode($api_response); // JSON decode
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}