PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/ext/php_xmlrpc/server-sample.php

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
PHP | 99 lines | 51 code | 24 blank | 24 comment | 1 complexity | ad882acc0d84b0c47ad9d6c30d32d793 MD5 | raw file
 1<?php
 2//error_reporting(E_ALL);
 3//ini_set('display_errors', '1');
 4include 'xmlrpc.inc';
 5include 'xmlrpcs.inc';
 6//testcommit
 7
 8//must exist for yabs
 9function getYWSIVersion () {
10    return new xmlrpcresp(new xmlrpcval(1, 'int'));
11}
12
13
14
15function addNewContact ($params) {
16
17//Parse our parameters. *should be a loop through $params instead*
18//Writing to a file as echoing will break the operation
19    if (!$handle = fopen("test.txt", 'w+')) {
20        exit;
21    }
22
23    //getParam(0) returns a 'xmlrpcval'
24
25    //serialized it looks like this:
26    //<value><array>
27    //<data>
28    //<value><string>1</string></value>
29    //<value><string>cname</string></value>
30    //<value><string>mustermann1</string></value>
31    //</data>
32    //</array></value>
33
34    //getParam(1) returns a 'xmlrpcval'
35    //<value><array>
36    //<data>
37    //<value><string>1</string></value>
38    //<value><string>city</string></value>
39    //<value><string>mustermannhausen</string></value>
40    //</data>
41    //</array></value>
42
43    fwrite($handle, $params->getParam(0)->serialize());
44    fwrite($handle, $params->getParam(1)->serialize());
45    fwrite($handle, $params->getParam(2)->serialize());
46    fwrite($handle, $params->getParam(3)->serialize());
47
48    fclose($handle);
49
50    // Build our response.
51    return new xmlrpcresp(new xmlrpcval(rand(), 'int'));
52}
53
54
55
56function getNewContacts($zeitraum) {
57
58    $arr =
59        array(
60
61        new xmlrpcval(array('id' => new xmlrpcval(0, 'int'),
62        'key' => new xmlrpcval('ids', 'int'),
63        'value' => new xmlrpcval(2000, 'int')), 'struct'),
64
65        new xmlrpcval(array('id' => new xmlrpcval(1, 'int'),
66        'key' => new xmlrpcval('ids', 'int'),
67        'value' => new xmlrpcval(2001, 'int')), 'struct'),
68
69        new xmlrpcval(array('id' => new xmlrpcval(0, 'int'),
70        'key' => new xmlrpcval('contactsids', 'int'),
71        'value' => new xmlrpcval(2, 'int')), 'struct'),
72
73        new xmlrpcval(array('id' => new xmlrpcval(0, 'int'),
74        'key' => new xmlrpcval('cname', 'string'),
75        'value' => new xmlrpcval('spaci76', 'string')), 'struct'),
76
77        new xmlrpcval(array('id' => new xmlrpcval(1, 'int'),
78        'key' => new xmlrpcval('contactsids', 'int'),
79        'value' => new xmlrpcval(3, 'int')), 'struct'),
80
81        new xmlrpcval(array('id' => new xmlrpcval(1, 'int'),
82        'key' => new xmlrpcval('cname', 'string'),
83        'value' => new xmlrpcval('spaci2009', 'string')), 'struct')
84    );
85
86    return new xmlrpcresp(new xmlrpcval($arr, 'struct'));
87}
88
89
90new xmlrpc_server(array('addNewContact' =>
91    array('function' => 'addNewContact')
92    ,
93    'getNewContacts' =>
94    array('function' => 'getNewContacts')
95    ,
96    'getYWSIVersion' =>
97    array('function'=> 'getYWSIVersion'))
98);
99?>