Note that there are some explanatory texts on larger screens.

plurals
  1. POCURL Delete request to Instagram API fails
    primarykey
    data
    text
    <p>I'm trying to unlike a photo that I just liked on Instagram with a call to the API. My url is exactly as the URL in instagrams API tool. Im using Curl. I get an empty response, no error or status code.</p> <p>Here is my "like/unlike" method written in javascript.</p> <pre><code>likeImage: function(type, id) { var params = "url=https://api.instagram.com/v1/media/" + id + "/likes"; if(type === 'DELETE') { params += "?access_token=" + localStorage.getItem('id') + "." + localStorage.getItem('token'); } else { params += "&amp;access_token=" + localStorage.getItem('id') + "." + localStorage.getItem('token'); } $.ajax({ url: "crossDomain.php", contentType: "application/x-www-form-urlencoded; charset=UTF-8", type: type, data: params, beforeSend: function () { console.log('Start' + type); }, complete: function(data) { console.log('Finished ' + type); }, success: function(data) { console.log('Success ' + type); console.log(data); }, error: function(jqXHR, textStatus, errorThrown) { console.log('JQXHR:' + jqXHR); console.log('TEXTSTATUS: ' + textStatus); console.log('ERROR THROWN:' + errorThrown); console.log('error'); } }); </code></pre> <p>And here is my Server Code written in PHP</p> <p> <pre><code>$method = $_SERVER['REQUEST_METHOD']; if($method == "POST") { $url = $_POST['url']; $token = $_POST['access_token']; $fields = array( "access_token" =&gt; urlencode($token) ); $fields_string = ""; foreach($fields as $key=&gt;$value) { $fields_string .= $key.'='.$value.'&amp;'; } rtrim($fields_string, '&amp;'); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); $result = curl_exec($ch); curl_close($ch); echo $result; } else if($method == 'DELETE') { $url = file_get_contents('php://input'); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); $result = curl_exec($ch); curl_close($ch); echo $result; } </code></pre> <p>My Like code works Perfectly... any thoughts? According to the documentation a DELETE request should look like this:</p> <pre><code>curl -X DELETE https://api.instagram.com/v1/media/{media-id}/likes?access_token=MYACCESSTOKEN </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload