如何在不使用CURL的情況下刪除API調用cloudflare?使用PHP調用CloudFlare但不使用Curl
我的託管服務提供商不提供我很難爲情服務
我特別感興趣,並想使PHP API調用的CloudFlare從緩存中清除所有文件。
在API頁面,我發現
然後做了研究,研究還研究並通過這樣做
<?php
$data = array (
"purge_everything" => true
);
$url = "https://api.cloudflare.com/client/v4/zones/MYZONEID/purge_cache";
$opts = array('http' =>
array(
'method' => 'DELETE',
'header' => "Content-Type: application/json\r\n" . "X-Auth-Key: MYKEY\r\n" . "X-Auth-Email: MYEMAIL\r\n",
'data' => json_encode($data)
)
);
$context = stream_context_create($opts);
$fp = @fopen($url, 'rb', false, $context);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
找到了一種方法(也許)但在這個
Fatal error: Uncaught Exception: Problem with https://api.cloudflare.com/client/v4/zones/MYZONEID/purge_cache, in /srv/disk11/2444530/www/xxxx.pl/test.php:16 Stack trace: #0 {main} thrown in /srv/disk11/2444530/www/xxxx.pl/test.php on line 16
遇到錯誤
我也試過這種方式:
<?php
$data = array (
"purge_everything" => true
);
$method = "getCallDetails";
$url = "https://api.cloudflare.com/client/v4/zones/MYZONEID/purge_cache";
$opts = array('http' =>
array(
'method' => 'DELETE',
'header' => "Content-Type: application/json\r\n" . "X-Auth-Key: MyKEY\r\n" . "X-Auth-Email: myEMAIL\r\n",
'data' => json_encode($data)
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
return $result;
還不錯的錯誤,這個時候:
Warning: file_get_contents(https://api.cloudflare.com/client/v4/zones/MYAPIID/purge_cache): failed to open stream: Network is unreachable in /srv/disk11/2444530/www/xxxx.pl/test.php on line 15
當我得到瀏覽器到我的https://api.cloudflare.com/client/v4/zones/MYAPIID/purge_cache
我看到
可達但不工作,東西在這裏很糟糕,甚至根本不可能。
那麼它是否可以使這件事情沒有CURL?如果是的話,該怎麼做?
有什麼不對實際使用捲曲? – BenM
@BenM我的託管服務不提供給我Curl –
如何使用非垃圾提供程序呢?我可以想象沒有SSH訪問,但沒有提供基本擴展之一? –