如何从PHP发送删除请求

时间:2011-10-15 16:52:25

标签: php facebook

我发现的最好的例子是:

$request_body = 'some data';
$ch = curl_init('http://www.example.com');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request_body);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
        $response = curl_exec($ch);
var_dump($response);

虽然这是为了删除FB应用程序请求,因此URL应如下所示:https://graph.facebook.com/[request_id]?access_token=USER_ACCESS_TOKEN

有人可以告诉我如何为我的案例实现该代码吗?

1 个答案:

答案 0 :(得分:3)

请勿使用curl_setopt($ch, CURLOPT_POSTFIELDS, $request_body);

使用

$ch = curl_init('https://graph.facebook.com/'.$request_uri.'&access_token='.$access_token);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$response = curl_exec($ch);
var_dump($response);
相关问题