需要PHP fsockopen帮助
我曾尝试使用cloudflare api,我在他们的文档中发现了这一点。不幸的是,我不知道如何在fsockopen或through curl中使用它。下面是POST请求的示例。我只需要知道如何使用curl或fsockopen将以下数据作为POST发出请求需要PHP fsockopen帮助,php,curl,fsockopen,cloudflare,Php,Curl,Fsockopen,Cloudflare,我曾尝试使用cloudflare api,我在他们的文档中发现了这一点。不幸的是,我不知道如何在fsockopen或through curl中使用它。下面是POST请求的示例。我只需要知道如何使用curl或fsockopen将以下数据作为POST发出请求 curl https://www.cloudflare.com/api_json.html -d 'a=cache_lvl' \ -d 'tkn=8afbe6dea02407989af4dd4c97bb6e25' \ -d 'email=sa
curl https://www.cloudflare.com/api_json.html
-d 'a=cache_lvl' \
-d 'tkn=8afbe6dea02407989af4dd4c97bb6e25' \
-d 'email=sample@example.com' \
-d 'z=example.com' \
-d 'v=agg'
这是指向cloudflare的链接
试试这个:
$ch = curl_init("https://www.cloudflare.com/api_json.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
// handling of -d curl parameter is here.
$param = array(
'a' => 'cache_lvl',
'tkn' => '8afbe6dea02407989af4dd4c97bb6e25',
'email' => 'sample@example.com',
'z' => 'ex'
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
$result = curl_exec($ch);
curl_close($ch);
print $result;
试试这个:
$ch = curl_init("https://www.cloudflare.com/api_json.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
// handling of -d curl parameter is here.
$param = array(
'a' => 'cache_lvl',
'tkn' => '8afbe6dea02407989af4dd4c97bb6e25',
'email' => 'sample@example.com',
'z' => 'ex'
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
$result = curl_exec($ch);
curl_close($ch);
print $result;
非常感谢它根据我的需要进行了一些更改,但再次感谢您为我指路。非常感谢它根据我的需要进行了一些更改,但再次感谢您为我指路。