无法从容器Cloud Flare获取对象

时间:2018-09-23 21:55:10

标签: php api cloud flare

我使用Cloud Flare API开发用于通过URL清除文件的php脚本

运行后,出现此错误:

{"success":false,"errors":[{"code":0,"message":"Failed to get an object from container."}],"messages":[],"result":null}

这是我的php脚本:

$data = '{"files":["http://www.example.com/page"]}';

$url = "https://api.cloudflare.com/client/v4/zones/myzone/purge_cache";
$opts = ['http' => [
    'method' => 'DELETE',
    'header' => [
        "Content-Type: application/json",
        "X-Auth-Key: myapi",
        "X-Auth-Email: myemail",
    ],
    'content' => json_encode($data),
]];
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);

echo $result;

也许我想念一些东西,这是我的第一个api。我已经阅读了文档https://api.cloudflare.com/#zone-purge-files-by-url,但没有运气。 有人对CF有更多的经验吗?

0 个答案:

没有答案