WIP - more fixes
[plcapi.git] / demo / vardemo.php
1 <html>
2 <head><title>xmlrpc</title></head>
3 <body>
4 <?php
5     include_once(__DIR__."/../vendor/autoload.php");
6
7     include_once(__DIR__."/../lib/xmlrpc.inc");
8
9     $f = new xmlrpcmsg('examples.getStateName');
10
11     print "<h3>Testing value serialization</h3>\n";
12
13     $v = new xmlrpcval(23, "int");
14     print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
15     $v = new xmlrpcval("What are you saying? >> << &&");
16     print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
17
18     $v = new xmlrpcval(array(
19         new xmlrpcval("ABCDEFHIJ"),
20         new xmlrpcval(1234, 'int'),
21         new xmlrpcval(1, 'boolean')),
22         "array"
23     );
24
25     print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
26
27     $v = new xmlrpcval(
28         array(
29             "thearray" => new xmlrpcval(
30                 array(
31                     new xmlrpcval("ABCDEFHIJ"),
32                     new xmlrpcval(1234, 'int'),
33                     new xmlrpcval(1, 'boolean'),
34                     new xmlrpcval(0, 'boolean'),
35                     new xmlrpcval(true, 'boolean'),
36                     new xmlrpcval(false, 'boolean')
37                 ),
38                 "array"
39             ),
40             "theint" => new xmlrpcval(23, 'int'),
41             "thestring" => new xmlrpcval("foobarwhizz"),
42             "thestruct" => new xmlrpcval(
43                 array(
44                     "one" => new xmlrpcval(1, 'int'),
45                     "two" => new xmlrpcval(2, 'int')
46                 ),
47                 "struct"
48             )
49         ),
50         "struct"
51     );
52
53     print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
54
55     $w = new xmlrpcval(array($v, new xmlrpcval("That was the struct!")), "array");
56
57     print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
58
59     $w = new xmlrpcval("Mary had a little lamb,
60 Whose fleece was white as snow,
61 And everywhere that Mary went
62 the lamb was sure to go.
63
64 Mary had a little lamb
65 She tied it to a pylon
66 Ten thousand volts went down its back
67 And turned it into nylon", "base64"
68     );
69     print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
70     print "<PRE>Value of base64 string is: '" . $w->scalarval() . "'</PRE>";
71
72     $f->method('');
73     $f->addParam(new xmlrpcval("41", "int"));
74
75     print "<h3>Testing request serialization</h3>\n";
76     $op = $f->serialize();
77     print "<PRE>" . htmlentities($op) . "</PRE>";
78
79     print "<h3>Testing ISO date format</h3><pre>\n";
80
81     $t = time();
82     $date = iso8601_encode($t);
83     print "Now is $t --> $date\n";
84     print "Or in UTC, that is " . iso8601_encode($t, 1) . "\n";
85     $tb = iso8601_decode($date);
86     print "That is to say $date --> $tb\n";
87     print "Which comes out at " . iso8601_encode($tb) . "\n";
88     print "Which was the time in UTC at " . iso8601_decode($date, 1) . "\n";
89
90     print "</pre>\n";
91 ?>
92 </body>
93 </html>