Php 通过API进行最大CDN清除
我正试图通过MaxCDNAPI清除一个文件,但它不起作用。这是我正在使用的代码。打印不会返回任何结果Php 通过API进行最大CDN清除,php,api,Php,Api,我正试图通过MaxCDNAPI清除一个文件,但它不起作用。这是我正在使用的代码。打印不会返回任何结果 function purge() { date_default_timezone_set('America/Los_Angeles'); $date = date('c'); $apiid = 'myapiid'; $apikey = 'myapi'; $auth_key = hash('sha256', $date.':'.$apikey.':purge
function purge() {
date_default_timezone_set('America/Los_Angeles');
$date = date('c');
$apiid = 'myapiid';
$apikey = 'myapi';
$auth_key = hash('sha256', $date.':'.$apikey.':purge');
$url = 'http://softsailor.alexdumitru.netdna-cdn.com/wp-content/themes/ss3/includes/sprite.jpg';
if (!class_exists('IXR_Client')) {
require_once (ABSPATH . WPINC . '/class-IXR.php');
}
$client = new IXR_Client('api.netdna.com','/xmlrpc/cache',80);
$client->timeout = 30;
$client->query('cache.purge', $apiid, $auth_string, $date, $url);
print_r($client->getResponse());
}
我打开了调试,出现了以下错误
出了点问题--32300:传输错误-HTTP状态代码不是200。我在MaxCDN工作,下面是我从我们的Wiki中获取的代码示例:
<?php
date_default_timezone_set('America/Los_Angeles');
include("lib/xmlrpc.inc");
$cur = date('c');
$apiKey = 'api-key';
$apiUserId = 'api-user-id';
$namespace = 'cache';
$method = 'purge';
$authString = hash('sha256', $cur . ':' . $apiKey . ':' . $method);
// this is the url to purge
$url= 'http://static.jdorfman.netdna-cdn.com/static/images/frugal-it-logo.png';
$f=new xmlrpcmsg("$namespace.$method", array(php_xmlrpc_encode($apiUserId),
php_xmlrpc_encode($authString), php_xmlrpc_encode($cur),
php_xmlrpc_encode($url)));
$c=new xmlrpc_client("/xmlrpc/cache", "api.netdna.com", 80,'http11');
$r=&$c->send($f);
print_r($r);
?>
如果您有任何其他问题或担忧,请随时与我联系:maxcdn.com上的jdorfmanjdorfman的示例转储整个原始响应,但如果您像我一样,您希望使用php将其放入数据对象中 以下是一些有用的提示: $r->序列化以仅访问原始XML响应 要转换为JSON,请使用以下命令: $xml=simplexml\u加载\u字符串$r->序列化;
echo json_encode$xml 你有一个.Net的工作示例吗?我正在使用NetDNA API页面中的示例,两个清除操作都不起作用。调用purgeAllCache返回无效的身份验证字符串,我很确定它不是,purge返回的解析请求失败。