OSDN Git Service

merged 3.15rc3 modification
[nucleus-jp/nucleus-jp-ancient.git] / euc / build / testcases / xmlrpc-metaWeblog-newMediaObject.php
1 <?php\r
2 /*\r
3         Test call to the nucleus XML-RPC server sending a metaWeblog.newMediaObject request\r
4         \r
5         Wouter Demuynck / 2003-08-31\r
6 */\r
7 \r
8 // URL of XML-RPC server\r
9 $serverHost = 'localhost';\r
10 $serverPost = 80;\r
11 $serverPath = '/release/nucleus/xmlrpc/server.php';\r
12         \r
13 include('../../config.php');\r
14 include($DIR_LIBS . 'xmlrpc.inc.php');\r
15 \r
16 // get file data\r
17 $filename = '../../nucleus/nucleus.gif';\r
18 $fh = fopen($filename,'rb');\r
19 $data = fread ($fh, filesize ($filename));\r
20 fclose($fh);\r
21 \r
22 $f=new xmlrpcmsg(\r
23         'metaWeblog.newMediaObject',\r
24          array(\r
25                 new xmlrpcval('1', 'string'),                   // blogid\r
26                 new xmlrpcval('god', 'string'),                 // username\r
27                 new xmlrpcval('heaven', 'string'),              // password\r
28                 new xmlrpcval(array(                                    // data\r
29                                 'name' => new xmlrpcval('myImage.gif', 'string'),\r
30                                 'type' => new xmlrpcval('image/gif', 'string'),\r
31                                 'bits' => new xmlrpcval($data, 'base64')\r
32                         ),              \r
33                         'struct'\r
34                 )\r
35          )\r
36  );\r
37          \r
38 \r
39   $c=new xmlrpc_client($serverPath, $serverHost, $serverPort);\r
40   $c->setDebug(1);\r
41   $r=$c->send($f);\r
42   $v=$r->value();\r
43 \r
44 \r
45   if (!$r->faultCode()) {\r
46         echo 'succes!';\r
47   } else {\r
48       print "Fault: ";\r
49       print "Code: " . $r->faultCode() . \r
50             " Reason '" .$r->faultString()."'<BR>";\r
51   }\r
52         \r
53 \r
54         \r
55 ?>