PageRenderTime 5ms CodeModel.GetById 0ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  1. <?php
  2. //error_reporting(E_ALL);
  3. //ini_set('display_errors', '1');
  4. include 'xmlrpc.inc';
  5. include 'xmlrpcs.inc';
  6. //testcommit
  7. //must exist for yabs
  8. function getYWSIVersion () {
  9. return new xmlrpcresp(new xmlrpcval(1, 'int'));
  10. }
  11. function addNewContact ($params) {
  12. //Parse our parameters. *should be a loop through $params instead*
  13. //Writing to a file as echoing will break the operation
  14. if (!$handle = fopen("test.txt", 'w+')) {
  15. exit;
  16. }
  17. //getParam(0) returns a 'xmlrpcval'
  18. //serialized it looks like this:
  19. //<value><array>
  20. //<data>
  21. //<value><string>1</string></value>
  22. //<value><string>cname</string></value>
  23. //<value><string>mustermann1</string></value>
  24. //</data>
  25. //</array></value>
  26. //getParam(1) returns a 'xmlrpcval'
  27. //<value><array>
  28. //<data>
  29. //<value><string>1</string></value>
  30. //<value><string>city</string></value>
  31. //<value><string>mustermannhausen</string></value>
  32. //</data>
  33. //</array></value>
  34. fwrite($handle, $params->getParam(0)->serialize());
  35. fwrite($handle, $params->getParam(1)->serialize());
  36. fwrite($handle, $params->getParam(2)->serialize());
  37. fwrite($handle, $params->getParam(3)->serialize());
  38. fclose($handle);
  39. // Build our response.
  40. return new xmlrpcresp(new xmlrpcval(rand(), 'int'));
  41. }
  42. function getNewContacts($zeitraum) {
  43. $arr =
  44. array(
  45. new xmlrpcval(array('id' => new xmlrpcval(0, 'int'),
  46. 'key' => new xmlrpcval('ids', 'int'),
  47. 'value' => new xmlrpcval(2000, 'int')), 'struct'),
  48. new xmlrpcval(array('id' => new xmlrpcval(1, 'int'),
  49. 'key' => new xmlrpcval('ids', 'int'),
  50. 'value' => new xmlrpcval(2001, 'int')), 'struct'),
  51. new xmlrpcval(array('id' => new xmlrpcval(0, 'int'),
  52. 'key' => new xmlrpcval('contactsids', 'int'),
  53. 'value' => new xmlrpcval(2, 'int')), 'struct'),
  54. new xmlrpcval(array('id' => new xmlrpcval(0, 'int'),
  55. 'key' => new xmlrpcval('cname', 'string'),
  56. 'value' => new xmlrpcval('spaci76', 'string')), 'struct'),
  57. new xmlrpcval(array('id' => new xmlrpcval(1, 'int'),
  58. 'key' => new xmlrpcval('contactsids', 'int'),
  59. 'value' => new xmlrpcval(3, 'int')), 'struct'),
  60. new xmlrpcval(array('id' => new xmlrpcval(1, 'int'),
  61. 'key' => new xmlrpcval('cname', 'string'),
  62. 'value' => new xmlrpcval('spaci2009', 'string')), 'struct')
  63. );
  64. return new xmlrpcresp(new xmlrpcval($arr, 'struct'));
  65. }
  66. new xmlrpc_server(array('addNewContact' =>
  67. array('function' => 'addNewContact')
  68. ,
  69. 'getNewContacts' =>
  70. array('function' => 'getNewContacts')
  71. ,
  72. 'getYWSIVersion' =>
  73. array('function'=> 'getYWSIVersion'))
  74. );
  75. ?>