views:

437

answers:

3

In PHP, I'm using curl to send a delete to the fb graph api - and yet I'm getting the following error;

{"error":{"type":"GraphMethodException","message":"Unsupported delete request."}}

The code I'm using is;

$ch = curl_init("https://graph.facebook.com/" . $status_id . ""); 
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);  
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_CAINFO, NULL); 
curl_setopt($ch, CURLOPT_CAPATH, NULL); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 

$result = curl_exec($ch); 
echo $result;

$query contains the access token.

A: 

The only thing I can think to try is to

1) do a POST request with "method=delete" to see if that works

2) manually look at the produced HTTP request to see if something looks wrong -- then you can isolate the problem

Thr4wn
Hi Thr4wn. I've tried to do POST with the method=delete but that didn't work either.
Simon R
A: 

It simply means that the HTTP delete method isn't supported for that specific object.

One option is to use Http POST and add method=delete to the parameter query. Make sure that your application has a publish_stream permission else you can never publish a feed. Permissions are done by Facebook.

The Elite Gentleman
+1  A: 

Fixed!

You have to prepend the userid to the object ID when deleting:

DELETE https://graph.facebook.com/673509687_104812882909249?access_token={access_token} where 673509687 is my userID and 104812882909249 is the objectID

James Hartig