OSDN Git Service

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