0
您好,我有索姆問題在PHP中編寫一個簡單的XML-RPC客戶端。 這是我的PHP代碼:如何在PHP的localhost xml_rpc客戶端上實現?
$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擴展。
刪除'@'並查看您獲得的錯誤消息。這應該對你有所幫助。另見http://php.net/error-reporting – hakre