您好,我在用 PHP 编写一个简单的 XML-RPC 客户端时遇到了一些问题。这是我的 PHP 代码:
$site_name = "Mikangali";
$site_url = "http://www.mikangali.com";
$site_url = "http://localhost";
$request = xmlrpc_encode_request("weblogUpdates.ping", array($site_name, $site_url));
#echo $request;
$http_request = array(
'method' => "POST",
'header' => "Content-Type: text/xml\r\nUser-Agent: PHPRPC/1.0\r\nHost: rpc.technorati.com\r\n",
'content' => $request
);
#print_r($http_request) ;
$context = stream_context_create(array('http' => $http_request));
$file = @file_get_contents($server_url, false, $context);
if ($file==false) {
#handle error here...
display_mssg("error","! we get a pb !");
}
$response = xmlrpc_decode($file);
if (is_array($response) and xmlrpc_is_fault($response)){
display_mssg("error","Failed to ping ".$site_name);
}
else {
display_mssg("success","Successfully pinged ".$site_name);
var_dump($response);
var_dump($file);
}
我不知道为什么它进入“成功”条件并向我显示:
! we get a pb !
Successfully pinged Technorati
null
boolean false
谢谢你的帮助。请注意,在我的本地 wamp 服务器上激活了 XML-RPC PHP 扩展。