OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@881 1ca29b6e-896d...
[nucleus-jp/nucleus-plugins.git] / NP_UpdatePingServer / trunk / ping_client_sample.php
1 <html>
2 <head>
3 <title>XML-RPC(PHP) Client Demo</title>
4 </head>
5 <body>
6 <h1>XML-RPC(PHP) Client Demo</h1>
7
8 <?php
9 $CONF = array();
10 include_once("./config.php");   // include Nucleus libs and code
11 include_once($DIR_LIBS . "xmlrpc.inc.php");
12 $xmlrpc_internalencoding = _CHARSET;
13 $xmlrpc_defencoding = 'UTF-8';
14
15 //クライアントの作成
16         $xmlrpc_host = "your host name";                                        // Nucleus を設置しているサーバのホスト名
17         $xmlrpc_path = "/?action=plugin&name=UodatePingServer&type=updateping"; // pingサーバスクリプトのパス
18 //      $xmlrpc_path = "/RPCS";                                                 // .htaccess を設定している時はこっち
19         $c = new xmlrpc_client( $xmlrpc_path, $xmlrpc_host, 80 );
20 //      $c->setDebug(1);                                                        // デバッグモードを有効にする場合はアンコメント
21
22 //メッセージ作成
23         $message = new xmlrpcmsg(
24         'weblogUpdates.ping',                                                   // pingメソッドの選択
25 //      'weblogUpdates.extendedPing',                                           // pingメソッドの選択
26                 array(
27                 new xmlrpcval('your weblog title'),                                 // ブログのタイトル
28                 new xmlrpcval('http://your.nucleus.url/path/'),                     // ブログのURL
29 //              new xmlrpcval('http://your.nucleus.url/path/to/contents/'),         // 変更があったコンテンツのURL(空白でも可)
30 //              new xmlrpcval('http://your.nucleus.url/path/to/feed.xml'),          // RSSやAtom等のURL
31                 )
32         );
33 /******* メソッドに weblogUpdates.extendedPing を指定した場合は、3、4番目が必須になります ******/
34
35 //メッセージ送信
36 $response = $c->send($message);
37
38 // Process the response.
39 if (!$response->faultCode()) {
40         $struct = $response->value();
41         $resultval =  $struct->structmem('message');
42     echo "Value: ".$resultval->scalarval();
43     echo "The XML received:<pre>" . htmlspecialchars($response->serialize());
44     echo "</pre>";
45
46 }else{
47     echo "Fault Code:   " . $response->faultCode()   . "<br>";
48     echo "Fault Reason: " . $response->faultString() . "<br>";
49     echo "The XML received:<pre>" . htmlspecialchars($response->serialize());
50     echo "</pre>";
51
52 }
53
54 ?>
55
56 </body>
57 </html>