Guest User

Untitled

a guest
May 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <?php
  2. /**
  3. * A simple example of the XML-RPC module that shows you how easy it is to expose
  4. * complex data types
  5. *
  6. * @package xmlrpc
  7. * @subpackage controllers
  8. */
  9. class XMLRPCExample extends XMLRPCServer {
  10.  
  11. /**
  12. * Returns a list of time zones
  13. *
  14. * @return array
  15. */
  16. public function timeZones() {
  17. return array (
  18. 'Server Time' => new DateTime('now'),
  19. 'Sydney Time' => new DateTime('now', new DateTimeZone('Australia/Sydney')),
  20. );
  21. }
  22.  
  23. /**
  24. * Returns all the methods passed to it
  25. *
  26. * @return arrau
  27. */
  28. public function methodArguments() {
  29. return func_get_args();
  30. }
  31.  
  32. /**
  33. * Throw an authentication error
  34. */
  35. public function authenticationError() {
  36. throw new XMLRPCException(-31000);
  37. }
  38.  
  39. // ---------------------------------------------------------------------------
  40.  
  41. /**
  42. * Exposes all the example methods to the XML-RPC interface
  43. */
  44. public function setMethods() {
  45. parent::setMethods();
  46.  
  47. $this->addMethod('example.timeZones', array($this, 'timeZones'));
  48. $this->addMethod('example.methodArguments', array($this, 'methodArguments'));
  49. $this->addMethod('example.authenticationError', array($this, 'authenticationError'));
  50. }
  51.  
  52. }
Add Comment
Please, Sign In to add comment