如何从PHP发送删除请求 [英] How to send a Delete request from PHP

查看:86
本文介绍了如何从PHP发送删除请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到的最好的例子是:

The best exemple i have found is:

$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

Though this is to deltete an FB app request so the URL should look like this: https://graph.facebook.com/[request_id]?access_token=USER_ACCESS_TOKEN

有人可以告诉我如何实现该代码对我来说

Could someone show me how to implement that code for my case ?

推荐答案

不要使用 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);

这篇关于如何从PHP发送删除请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆