0

こんにちは私は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-RPCPHP拡張がアクティブ化されていることに注意してください。

4

1 に答える 1

0

確かxmlrpc_decode(false)に戻っnull $file = falseてきたので、問題が発生します。(=> !pbを取得します!

$responseしたがって、配列であるかどうかをチェックしているifには入りません。

于 2011-11-10T16:18:56.523 に答える