xmlrpc.html 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>XML-RPC and XML-RPC Server Classes &mdash; CodeIgniter 3.1.11 documentation</title>
  8. <link rel="shortcut icon" href="../_static/ci-icon.ico"/>
  9. <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
  10. <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
  11. <link rel="index" title="Index"
  12. href="../genindex.html"/>
  13. <link rel="search" title="Search" href="../search.html"/>
  14. <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/>
  15. <link rel="up" title="Libraries" href="index.html"/>
  16. <link rel="next" title="Zip Encoding Class" href="zip.html"/>
  17. <link rel="prev" title="User Agent Class" href="user_agent.html"/>
  18. <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
  19. </head>
  20. <body class="wy-body-for-nav" role="document">
  21. <div id="nav">
  22. <div id="nav_inner">
  23. <div id="pulldown-menu" class="ciNav">
  24. <ul>
  25. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  26. </ul>
  27. <ul>
  28. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  29. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  30. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  31. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  32. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  33. </ul>
  34. </li>
  35. </ul>
  36. <ul>
  37. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  38. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  39. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  44. </ul>
  45. </li>
  46. </ul>
  47. <ul>
  48. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  49. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  52. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  53. </ul>
  54. </li>
  55. </ul>
  56. <ul>
  57. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  58. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  59. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  60. </ul>
  61. </li>
  62. </ul>
  63. <ul>
  64. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  65. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  66. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  67. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  68. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  69. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  70. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  71. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  72. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  73. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  74. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  75. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  76. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  77. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  78. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  79. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  80. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  81. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  82. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  83. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  84. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  85. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  86. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  87. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  88. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  89. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  90. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  91. </ul>
  92. </li>
  93. </ul>
  94. <ul class="current">
  95. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current">
  96. <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li>
  97. <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li>
  98. <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li>
  99. <li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li>
  100. <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li>
  101. <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li>
  102. <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li>
  103. <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li>
  104. <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li>
  105. <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li>
  106. <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li>
  107. <li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li>
  108. <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li>
  109. <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li>
  110. <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li>
  111. <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li>
  112. <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li>
  113. <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li>
  114. <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li>
  115. <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li>
  116. <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li>
  117. <li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li>
  118. <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li>
  119. <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li>
  120. <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li>
  121. <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li>
  122. <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li>
  123. <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li>
  124. <li class="toctree-l2 current"><a class="current reference internal" href="#">XML-RPC and XML-RPC Server Classes</a></li>
  125. <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li>
  126. </ul>
  127. </li>
  128. </ul>
  129. <ul>
  130. <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
  131. <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
  132. <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
  133. <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
  134. <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
  135. <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
  136. <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
  137. <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
  138. <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
  139. <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
  140. <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
  141. <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
  142. <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
  143. <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
  144. <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
  145. </ul>
  146. </li>
  147. </ul>
  148. <ul>
  149. <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
  150. <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
  151. <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li>
  152. <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
  153. <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
  154. <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li>
  155. <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li>
  156. <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li>
  157. <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li>
  158. <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
  159. <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
  160. <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
  161. <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li>
  162. <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
  163. <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li>
  164. <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
  165. <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li>
  166. <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li>
  167. <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
  168. <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li>
  169. <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
  170. <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
  171. </ul>
  172. </li>
  173. </ul>
  174. </div>
  175. </div>
  176. </div>
  177. <div id="nav2">
  178. <a href="#" id="openToc">
  179. <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAKwCaAwERAAIRAQMRAf/EAHsAAQAABwEBAAAAAAAAAAAAAAABAwQFBgcIAgkBAQAAAAAAAAAAAAAAAAAAAAAQAAEDAwICBwYEAgsAAAAAAAIBAwQAEQUSBiEHkROTVNQWGDFBUVIUCHEiMtOUFWGBobHRQlMkZIRVEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwDSC+ygkOOaUoKigUCgUCgUCgUCgUCgUCgUCgkuGguIP9FBMFb0Hqg7We+3jlmIqqYFf4ub+/QYlnOR/LqIBKGFUbf8qWv971BytQXXE7Y3Lnm3HsFhp2TaZJAdchRXpIgSpdEJWxJEW3xoKV7F5OMy7JkQn2o7D6w33XGjEAkoiqrJEqIiOIiKuhePCgqp22dyYyS3CyWHnQ5joG61HkRnmnTbaFSMhExRVQRRVJU9iUHjE7ez+fJ0MFipmUNhBV8YUd2SoIV9KkjQla9ltegttBdPLW4/qocL+UTfrMiHW4+P9M71shuyrqaHTcxsl7jegpsji8nh5ZwMvDfgTm0RTjSmjYdFCS6KoOIipdFunCgmNYTMv457MMY6U7iI6oMieDDhRm1VbIhuoOkbqtuK0Hpzb+eZcYZexUxt6UyUqK2cd0SdjtgrhOgijcgERUlJOCIl6CpgbP3blRI8XgMjNARAyKNDfeRBdFDBVUAXgQrqH4pxoJTu2NysY97LP4ac1io5q1InHFeGO24LnVKJuKOkSQ/yKir+rh7aCLG1dzypZQI2FnvTgccYOM3FeN0XWERXAUEFVQgQkUktdLpegm+Td3/Xli/L+S/mYNJIOF9G/wBeLKrZHFb0akG6W1WtQWSg3Dyg5e7V3fipE3O4/wCrktyzYA+ufas2LbZIlmnAT2kvuoN1wft95augilglX/tzP3qCu9O3LL/wV/i5v79BvmTADq14UGu91467Z6U9y0HzH/ncj/U/sT/CgynZG7I2NezpZGUjIycJkYkZSG+uQ81pbBNKLxJfjwoMqZ3/ALYHl35AJ7/cuwHcu5k7r1Q5pHetBjquqVVJWGxj9Zrtcl/Ggy3dHMvauR3HFZj5nHNxSyW5JISYDMoIwx8tFIGHZhPNaykGapr6rUAiicEoMG21lMRj8buPAz8xhJrr7uOeiPTCyAwXUaGR1mgozbTusOsFLEiJ7fbQa/h7gcjy2H3V6xppwDNtUSxCJIqp7valBuWVzJ22xuCROXNNZiJkMtms0DbjUkAZjzoDrTMd9dDRI44ZC2YsrYdKWP2WDT2S3N9dNdlRYrGMYc06IURXSYb0igrpWS485xVNS6nF4rwslkoMwnbpgZLB7bmt5uMweAhDEl4B5uSLzzqTnnyVpW2jaJHRMSIjdDiiotvy3DOE5rYTEbkl5yFn28k7JyG4c7AU2HtLH1uKfaiMPI40CdYbpNtmLdwTSn5rewLNld+7TLdeal4WarWBkbVKBjgdElMJJwAAY5fl4kB3b1fp4XvagsGS3FjJfLzDNtS8aeXx7LzT7TyzByQE5PccRGRC0ZRUDRV6y62vbjagzLmJzS2vuPK43JY6aP1TW6Jz+RIWyFtyC06y3EkiiinAo7YCqfq1AqqnGgsOH3lhZO8d1pmcpB8j5XIm9OYlBJSQ/FSS4427DKO0RC8AlcEMhFdViRR1WDWR5t3WXVuL1d106kG9vdeye2g60+1FDyW0shIcXVpyroXt8I8dfd+NB1vioAdWnD3UF1+gD4UFc6CEKpagxXN43rwJLUHz7yX2c8zokt9uHlsPIhA4aRnnHJTLptIS6CNsY7iASpxUUMkReGpfbQW0vtN5pitvrsN28rwtBD0nc0+/Yft5XhaB6TuaXfsP28rwtA9J3NPv2H7eV4Wgek7mn37D9vK8LQPSdzT79h+3leFoHpO5pd+w/byvC0D0nc0u/Yft5XhaB6TuaXfsP28rwtA9J3NLv2H7eV4Wgek7ml37D9vK8LQPSdzS79h+3leFoHpO5p9+w/byvC0E9r7Reazy2HIYVPxkS/CUHVn26cosxyv2g7h89LYmZSXOenvLEQ1YaQ222RATcQCP8rSGqqA8S02W2pQ6FhMoAIlqCtsnwoCpdKClejI4i3Sgtb+GBxVuNBSFt1pV/RQefLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8utJ/koJ7WCbBU/LQXOPAFq1koK8B0pag90CggtBBf6qB0UDooHRQOigdFA6KB0UDooHRQOigdFA6KB0UDooI0EaBQf//Z" title="Toggle Table of Contents" alt="Toggle Table of Contents" />
  180. </a>
  181. </div>
  182. <div class="wy-grid-for-nav">
  183. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  184. <div class="wy-side-nav-search">
  185. <a href="../index.html" class="fa fa-home"> CodeIgniter</a>
  186. <div role="search">
  187. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  188. <input type="text" name="q" placeholder="Search docs" />
  189. <input type="hidden" name="check_keywords" value="yes" />
  190. <input type="hidden" name="area" value="default" />
  191. </form>
  192. </div>
  193. </div>
  194. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  195. <ul>
  196. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  197. </ul>
  198. <ul>
  199. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  200. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  201. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  202. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  203. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  204. </ul>
  205. </li>
  206. </ul>
  207. <ul>
  208. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  209. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  210. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  211. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  212. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  213. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  214. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  215. </ul>
  216. </li>
  217. </ul>
  218. <ul>
  219. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  220. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  221. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  222. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  223. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  224. </ul>
  225. </li>
  226. </ul>
  227. <ul>
  228. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  229. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  230. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  231. </ul>
  232. </li>
  233. </ul>
  234. <ul>
  235. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  236. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  237. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  238. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  239. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  240. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  241. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  242. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  243. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  244. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  245. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  246. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  247. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  248. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  249. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  250. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  251. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  252. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  253. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  254. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  255. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  256. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  257. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  258. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  259. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  260. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  261. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  262. </ul>
  263. </li>
  264. </ul>
  265. <ul class="current">
  266. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current">
  267. <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li>
  268. <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li>
  269. <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li>
  270. <li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li>
  271. <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li>
  272. <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li>
  273. <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li>
  274. <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li>
  275. <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li>
  276. <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li>
  277. <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li>
  278. <li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li>
  279. <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li>
  280. <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li>
  281. <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li>
  282. <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li>
  283. <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li>
  284. <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li>
  285. <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li>
  286. <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li>
  287. <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li>
  288. <li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li>
  289. <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li>
  290. <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li>
  291. <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li>
  292. <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li>
  293. <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li>
  294. <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li>
  295. <li class="toctree-l2 current"><a class="current reference internal" href="#">XML-RPC and XML-RPC Server Classes</a></li>
  296. <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li>
  297. </ul>
  298. </li>
  299. </ul>
  300. <ul>
  301. <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
  302. <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
  303. <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
  304. <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
  305. <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
  306. <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
  307. <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
  308. <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
  309. <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
  310. <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
  311. <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
  312. <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
  313. <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
  314. <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
  315. <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
  316. </ul>
  317. </li>
  318. </ul>
  319. <ul>
  320. <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
  321. <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
  322. <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li>
  323. <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
  324. <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
  325. <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li>
  326. <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li>
  327. <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li>
  328. <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li>
  329. <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
  330. <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
  331. <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
  332. <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li>
  333. <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
  334. <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li>
  335. <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
  336. <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li>
  337. <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li>
  338. <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
  339. <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li>
  340. <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
  341. <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
  342. </ul>
  343. </li>
  344. </ul>
  345. </div>
  346. &nbsp;
  347. </nav>
  348. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  349. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  350. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  351. <a href="../index.html">CodeIgniter</a>
  352. </nav>
  353. <div class="wy-nav-content">
  354. <div class="rst-content">
  355. <div role="navigation" aria-label="breadcrumbs navigation">
  356. <ul class="wy-breadcrumbs">
  357. <li><a href="../index.html">Docs</a> &raquo;</li>
  358. <li><a href="index.html">Libraries</a> &raquo;</li>
  359. <li>XML-RPC and XML-RPC Server Classes</li>
  360. <li class="wy-breadcrumbs-aside">
  361. </li>
  362. <div style="float:right;margin-left:5px;" id="closeMe">
  363. <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" />
  364. </div>
  365. </ul>
  366. <hr/>
  367. </div>
  368. <div role="main" class="document">
  369. <div class="section" id="xml-rpc-and-xml-rpc-server-classes">
  370. <h1>XML-RPC and XML-RPC Server Classes<a class="headerlink" href="#xml-rpc-and-xml-rpc-server-classes" title="Permalink to this headline">¶</a></h1>
  371. <p>CodeIgniter’s XML-RPC classes permit you to send requests to another
  372. server, or set up your own XML-RPC server to receive requests.</p>
  373. <div class="contents local topic" id="contents">
  374. <ul class="simple">
  375. <li><a class="reference internal" href="#what-is-xml-rpc" id="id3">What is XML-RPC?</a></li>
  376. <li><a class="reference internal" href="#using-the-xml-rpc-class" id="id4">Using the XML-RPC Class</a><ul>
  377. <li><a class="reference internal" href="#initializing-the-class" id="id5">Initializing the Class</a></li>
  378. <li><a class="reference internal" href="#sending-xml-rpc-requests" id="id6">Sending XML-RPC Requests</a><ul>
  379. <li><a class="reference internal" href="#explanation" id="id7">Explanation</a></li>
  380. </ul>
  381. </li>
  382. <li><a class="reference internal" href="#anatomy-of-a-request" id="id8">Anatomy of a Request</a></li>
  383. <li><a class="reference internal" href="#creating-an-xml-rpc-server" id="id9">Creating an XML-RPC Server</a></li>
  384. <li><a class="reference internal" href="#processing-server-requests" id="id10">Processing Server Requests</a><ul>
  385. <li><a class="reference internal" href="#notes" id="id11">Notes:</a></li>
  386. </ul>
  387. </li>
  388. <li><a class="reference internal" href="#formatting-a-response" id="id12">Formatting a Response</a></li>
  389. <li><a class="reference internal" href="#sending-an-error-response" id="id13">Sending an Error Response</a></li>
  390. <li><a class="reference internal" href="#creating-your-own-client-and-server" id="id14">Creating Your Own Client and Server</a><ul>
  391. <li><a class="reference internal" href="#the-client" id="id15">The Client</a></li>
  392. <li><a class="reference internal" href="#the-server" id="id16">The Server</a></li>
  393. <li><a class="reference internal" href="#try-it" id="id17">Try it!</a></li>
  394. </ul>
  395. </li>
  396. <li><a class="reference internal" href="#using-associative-arrays-in-a-request-parameter" id="id18">Using Associative Arrays In a Request Parameter</a></li>
  397. <li><a class="reference internal" href="#id2" id="id19">Data Types</a></li>
  398. </ul>
  399. </li>
  400. <li><a class="reference internal" href="#class-reference" id="id20">Class Reference</a></li>
  401. </ul>
  402. </div>
  403. <div class="custom-index container"></div><div class="section" id="what-is-xml-rpc">
  404. <h2><a class="toc-backref" href="#id3">What is XML-RPC?</a><a class="headerlink" href="#what-is-xml-rpc" title="Permalink to this headline">¶</a></h2>
  405. <p>Quite simply it is a way for two computers to communicate over the
  406. internet using XML. One computer, which we will call the client, sends
  407. an XML-RPC <strong>request</strong> to another computer, which we will call the
  408. server. Once the server receives and processes the request it will send
  409. back a <strong>response</strong> to the client.</p>
  410. <p>For example, using the MetaWeblog API, an XML-RPC Client (usually a
  411. desktop publishing tool) will send a request to an XML-RPC Server
  412. running on your site. This request might be a new weblog entry being
  413. sent for publication, or it could be a request for an existing entry for
  414. editing. When the XML-RPC Server receives this request it will examine
  415. it to determine which class/method should be called to process the
  416. request. Once processed, the server will then send back a response
  417. message.</p>
  418. <p>For detailed specifications, you can visit the <a class="reference external" href="http://www.xmlrpc.com/">XML-RPC</a> site.</p>
  419. </div>
  420. <div class="section" id="using-the-xml-rpc-class">
  421. <h2><a class="toc-backref" href="#id4">Using the XML-RPC Class</a><a class="headerlink" href="#using-the-xml-rpc-class" title="Permalink to this headline">¶</a></h2>
  422. <div class="section" id="initializing-the-class">
  423. <h3><a class="toc-backref" href="#id5">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h3>
  424. <p>Like most other classes in CodeIgniter, the XML-RPC and XML-RPCS classes
  425. are initialized in your controller using the $this-&gt;load-&gt;library
  426. function:</p>
  427. <p>To load the XML-RPC class you will use:</p>
  428. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpc&#39;</span><span class="p">);</span>
  429. </pre></div>
  430. </div>
  431. <p>Once loaded, the xml-rpc library object will be available using:
  432. $this-&gt;xmlrpc</p>
  433. <p>To load the XML-RPC Server class you will use:</p>
  434. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpc&#39;</span><span class="p">);</span>
  435. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpcs&#39;</span><span class="p">);</span>
  436. </pre></div>
  437. </div>
  438. <p>Once loaded, the xml-rpcs library object will be available using:
  439. $this-&gt;xmlrpcs</p>
  440. <div class="admonition note">
  441. <p class="first admonition-title">Note</p>
  442. <p class="last">When using the XML-RPC Server class you must load BOTH the
  443. XML-RPC class and the XML-RPC Server class.</p>
  444. </div>
  445. </div>
  446. <div class="section" id="sending-xml-rpc-requests">
  447. <h3><a class="toc-backref" href="#id6">Sending XML-RPC Requests</a><a class="headerlink" href="#sending-xml-rpc-requests" title="Permalink to this headline">¶</a></h3>
  448. <p>To send a request to an XML-RPC server you must specify the following
  449. information:</p>
  450. <ul class="simple">
  451. <li>The URL of the server</li>
  452. <li>The method on the server you wish to call</li>
  453. <li>The <em>request</em> data (explained below).</li>
  454. </ul>
  455. <p>Here is a basic example that sends a simple Weblogs.com ping to the
  456. <a class="reference external" href="http://pingomatic.com/">Ping-o-Matic</a></p>
  457. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpc&#39;</span><span class="p">);</span>
  458. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">server</span><span class="p">(</span><span class="s1">&#39;http://rpc.pingomatic.com/&#39;</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span>
  459. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">method</span><span class="p">(</span><span class="s1">&#39;weblogUpdates.ping&#39;</span><span class="p">);</span>
  460. <span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;My Photoblog&#39;</span><span class="p">,</span> <span class="s1">&#39;http://www.my-site.com/photoblog/&#39;</span><span class="p">);</span>
  461. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span>
  462. <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">send_request</span><span class="p">())</span>
  463. <span class="p">{</span>
  464. <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">display_error</span><span class="p">();</span>
  465. <span class="p">}</span>
  466. </pre></div>
  467. </div>
  468. <div class="section" id="explanation">
  469. <h4><a class="toc-backref" href="#id7">Explanation</a><a class="headerlink" href="#explanation" title="Permalink to this headline">¶</a></h4>
  470. <p>The above code initializes the XML-RPC class, sets the server URL and
  471. method to be called (weblogUpdates.ping). The request (in this case, the
  472. title and URL of your site) is placed into an array for transportation,
  473. and compiled using the request() function. Lastly, the full request is
  474. sent. If the send_request() method returns false we will display the
  475. error message sent back from the XML-RPC Server.</p>
  476. </div>
  477. </div>
  478. <div class="section" id="anatomy-of-a-request">
  479. <h3><a class="toc-backref" href="#id8">Anatomy of a Request</a><a class="headerlink" href="#anatomy-of-a-request" title="Permalink to this headline">¶</a></h3>
  480. <p>An XML-RPC request is simply the data you are sending to the XML-RPC
  481. server. Each piece of data in a request is referred to as a request
  482. parameter. The above example has two parameters: The URL and title of
  483. your site. When the XML-RPC server receives your request, it will look
  484. for parameters it requires.</p>
  485. <p>Request parameters must be placed into an array for transportation, and
  486. each parameter can be one of seven data types (strings, numbers, dates,
  487. etc.). If your parameters are something other than strings you will have
  488. to include the data type in the request array.</p>
  489. <p>Here is an example of a simple array with three parameters:</p>
  490. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;John&#39;</span><span class="p">,</span> <span class="s1">&#39;Doe&#39;</span><span class="p">,</span> <span class="s1">&#39;www.some-site.com&#39;</span><span class="p">);</span>
  491. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span>
  492. </pre></div>
  493. </div>
  494. <p>If you use data types other than strings, or if you have several
  495. different data types, you will place each parameter into its own array,
  496. with the data type in the second position:</p>
  497. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  498. <span class="k">array</span><span class="p">(</span><span class="s1">&#39;John&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  499. <span class="k">array</span><span class="p">(</span><span class="s1">&#39;Doe&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  500. <span class="k">array</span><span class="p">(</span><span class="k">FALSE</span><span class="p">,</span> <span class="s1">&#39;boolean&#39;</span><span class="p">),</span>
  501. <span class="k">array</span><span class="p">(</span><span class="mi">12345</span><span class="p">,</span> <span class="s1">&#39;int&#39;</span><span class="p">)</span>
  502. <span class="p">);</span>
  503. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span>
  504. </pre></div>
  505. </div>
  506. <p>The <a class="reference external" href="#datatypes">Data Types</a> section below has a full list of data
  507. types.</p>
  508. </div>
  509. <div class="section" id="creating-an-xml-rpc-server">
  510. <h3><a class="toc-backref" href="#id9">Creating an XML-RPC Server</a><a class="headerlink" href="#creating-an-xml-rpc-server" title="Permalink to this headline">¶</a></h3>
  511. <p>An XML-RPC Server acts as a traffic cop of sorts, waiting for incoming
  512. requests and redirecting them to the appropriate functions for
  513. processing.</p>
  514. <p>To create your own XML-RPC server involves initializing the XML-RPC
  515. Server class in your controller where you expect the incoming request to
  516. appear, then setting up an array with mapping instructions so that
  517. incoming requests can be sent to the appropriate class and method for
  518. processing.</p>
  519. <p>Here is an example to illustrate:</p>
  520. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpc&#39;</span><span class="p">);</span>
  521. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpcs&#39;</span><span class="p">);</span>
  522. <span class="nv">$config</span><span class="p">[</span><span class="s1">&#39;functions&#39;</span><span class="p">][</span><span class="s1">&#39;new_post&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;function&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;My_blog.new_entry&#39;</span><span class="p">);</span>
  523. <span class="nv">$config</span><span class="p">[</span><span class="s1">&#39;functions&#39;</span><span class="p">][</span><span class="s1">&#39;update_post&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;function&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;My_blog.update_entry&#39;</span><span class="p">);</span>
  524. <span class="nv">$config</span><span class="p">[</span><span class="s1">&#39;object&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="p">;</span>
  525. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpcs</span><span class="o">-&gt;</span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span>
  526. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpcs</span><span class="o">-&gt;</span><span class="na">serve</span><span class="p">();</span>
  527. </pre></div>
  528. </div>
  529. <p>The above example contains an array specifying two method requests that
  530. the Server allows. The allowed methods are on the left side of the
  531. array. When either of those are received, they will be mapped to the
  532. class and method on the right.</p>
  533. <p>The ‘object’ key is a special key that you pass an instantiated class
  534. object with, which is necessary when the method you are mapping to is
  535. not part of the CodeIgniter super object.</p>
  536. <p>In other words, if an XML-RPC Client sends a request for the new_post
  537. method, your server will load the My_blog class and call the new_entry
  538. function. If the request is for the update_post method, your server
  539. will load the My_blog class and call the <code class="docutils literal"><span class="pre">update_entry()</span></code> method.</p>
  540. <p>The function names in the above example are arbitrary. You’ll decide
  541. what they should be called on your server, or if you are using
  542. standardized APIs, like the Blogger or MetaWeblog API, you’ll use their
  543. function names.</p>
  544. <p>There are two additional configuration keys you may make use of when
  545. initializing the server class: debug can be set to TRUE in order to
  546. enable debugging, and xss_clean may be set to FALSE to prevent sending
  547. data through the Security library’s <code class="docutils literal"><span class="pre">xss_clean()</span></code> method.</p>
  548. </div>
  549. <div class="section" id="processing-server-requests">
  550. <h3><a class="toc-backref" href="#id10">Processing Server Requests</a><a class="headerlink" href="#processing-server-requests" title="Permalink to this headline">¶</a></h3>
  551. <p>When the XML-RPC Server receives a request and loads the class/method
  552. for processing, it will pass an object to that method containing the
  553. data sent by the client.</p>
  554. <p>Using the above example, if the new_post method is requested, the
  555. server will expect a class to exist with this prototype:</p>
  556. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">My_blog</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span>
  557. <span class="k">public</span> <span class="k">function</span> <span class="nf">new_post</span><span class="p">(</span><span class="nv">$request</span><span class="p">)</span>
  558. <span class="p">{</span>
  559. <span class="p">}</span>
  560. <span class="p">}</span>
  561. </pre></div>
  562. </div>
  563. <p>The $request variable is an object compiled by the Server, which
  564. contains the data sent by the XML-RPC Client. Using this object you will
  565. have access to the <em>request parameters</em> enabling you to process the
  566. request. When you are done you will send a Response back to the Client.</p>
  567. <p>Below is a real-world example, using the Blogger API. One of the methods
  568. in the Blogger API is <code class="docutils literal"><span class="pre">getUserInfo()</span></code>. Using this method, an XML-RPC
  569. Client can send the Server a username and password, in return the Server
  570. sends back information about that particular user (nickname, user ID,
  571. email address, etc.). Here is how the processing function might look:</p>
  572. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">My_blog</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span>
  573. <span class="k">public</span> <span class="k">function</span> <span class="nf">getUserInfo</span><span class="p">(</span><span class="nv">$request</span><span class="p">)</span>
  574. <span class="p">{</span>
  575. <span class="nv">$username</span> <span class="o">=</span> <span class="s1">&#39;smitty&#39;</span><span class="p">;</span>
  576. <span class="nv">$password</span> <span class="o">=</span> <span class="s1">&#39;secretsmittypass&#39;</span><span class="p">;</span>
  577. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpc&#39;</span><span class="p">);</span>
  578. <span class="nv">$parameters</span> <span class="o">=</span> <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">output_parameters</span><span class="p">();</span>
  579. <span class="k">if</span> <span class="p">(</span><span class="nv">$parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="nv">$username</span> <span class="o">&amp;&amp;</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">!=</span> <span class="nv">$password</span><span class="p">)</span>
  580. <span class="p">{</span>
  581. <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">send_error_message</span><span class="p">(</span><span class="s1">&#39;100&#39;</span><span class="p">,</span> <span class="s1">&#39;Invalid Access&#39;</span><span class="p">);</span>
  582. <span class="p">}</span>
  583. <span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  584. <span class="k">array</span><span class="p">(</span>
  585. <span class="s1">&#39;nickname&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;Smitty&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  586. <span class="s1">&#39;userid&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;99&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  587. <span class="s1">&#39;url&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;http://yoursite.com&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  588. <span class="s1">&#39;email&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;jsmith@yoursite.com&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  589. <span class="s1">&#39;lastname&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;Smith&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  590. <span class="s1">&#39;firstname&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;John&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span>
  591. <span class="p">),</span>
  592. <span class="s1">&#39;struct&#39;</span>
  593. <span class="p">);</span>
  594. <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">send_response</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span>
  595. <span class="p">}</span>
  596. <span class="p">}</span>
  597. </pre></div>
  598. </div>
  599. <div class="section" id="notes">
  600. <h4><a class="toc-backref" href="#id11">Notes:</a><a class="headerlink" href="#notes" title="Permalink to this headline">¶</a></h4>
  601. <p>The <code class="docutils literal"><span class="pre">output_parameters()</span></code> method retrieves an indexed array
  602. corresponding to the request parameters sent by the client. In the above
  603. example, the output parameters will be the username and password.</p>
  604. <p>If the username and password sent by the client were not valid, and
  605. error message is returned using <code class="docutils literal"><span class="pre">send_error_message()</span></code>.</p>
  606. <p>If the operation was successful, the client will be sent back a response
  607. array containing the user’s info.</p>
  608. </div>
  609. </div>
  610. <div class="section" id="formatting-a-response">
  611. <h3><a class="toc-backref" href="#id12">Formatting a Response</a><a class="headerlink" href="#formatting-a-response" title="Permalink to this headline">¶</a></h3>
  612. <p>Similar to <em>Requests</em>, <em>Responses</em> must be formatted as an array.
  613. However, unlike requests, a response is an array <strong>that contains a
  614. single item</strong>. This item can be an array with several additional arrays,
  615. but there can be only one primary array index. In other words, the basic
  616. prototype is this:</p>
  617. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;Response data&#39;</span><span class="p">,</span> <span class="s1">&#39;array&#39;</span><span class="p">);</span>
  618. </pre></div>
  619. </div>
  620. <p>Responses, however, usually contain multiple pieces of information. In
  621. order to accomplish this we must put the response into its own array so
  622. that the primary array continues to contain a single piece of data.
  623. Here’s an example showing how this might be accomplished:</p>
  624. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  625. <span class="k">array</span><span class="p">(</span>
  626. <span class="s1">&#39;first_name&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;John&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  627. <span class="s1">&#39;last_name&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;Doe&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span>
  628. <span class="s1">&#39;member_id&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="mi">123435</span><span class="p">,</span> <span class="s1">&#39;int&#39;</span><span class="p">),</span>
  629. <span class="s1">&#39;todo_list&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">&#39;clean house&#39;</span><span class="p">,</span> <span class="s1">&#39;call mom&#39;</span><span class="p">,</span> <span class="s1">&#39;water plants&#39;</span><span class="p">),</span> <span class="s1">&#39;array&#39;</span><span class="p">),</span>
  630. <span class="p">),</span>
  631. <span class="s1">&#39;struct&#39;</span>
  632. <span class="p">);</span>
  633. </pre></div>
  634. </div>
  635. <p>Notice that the above array is formatted as a struct. This is the most
  636. common data type for responses.</p>
  637. <p>As with Requests, a response can be one of the seven data types listed
  638. in the <a class="reference external" href="#datatypes">Data Types</a> section.</p>
  639. </div>
  640. <div class="section" id="sending-an-error-response">
  641. <h3><a class="toc-backref" href="#id13">Sending an Error Response</a><a class="headerlink" href="#sending-an-error-response" title="Permalink to this headline">¶</a></h3>
  642. <p>If you need to send the client an error response you will use the
  643. following:</p>
  644. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">send_error_message</span><span class="p">(</span><span class="s1">&#39;123&#39;</span><span class="p">,</span> <span class="s1">&#39;Requested data not available&#39;</span><span class="p">);</span>
  645. </pre></div>
  646. </div>
  647. <p>The first parameter is the error number while the second parameter is
  648. the error message.</p>
  649. </div>
  650. <div class="section" id="creating-your-own-client-and-server">
  651. <h3><a class="toc-backref" href="#id14">Creating Your Own Client and Server</a><a class="headerlink" href="#creating-your-own-client-and-server" title="Permalink to this headline">¶</a></h3>
  652. <p>To help you understand everything we’ve covered thus far, let’s create a
  653. couple controllers that act as XML-RPC Client and Server. You’ll use the
  654. Client to send a request to the Server and receive a response.</p>
  655. <div class="section" id="the-client">
  656. <h4><a class="toc-backref" href="#id15">The Client</a><a class="headerlink" href="#the-client" title="Permalink to this headline">¶</a></h4>
  657. <p>Using a text editor, create a controller called Xmlrpc_client.php. In
  658. it, place this code and save it to your application/controllers/
  659. folder:</p>
  660. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
  661. <span class="k">class</span> <span class="nc">Xmlrpc_client</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span>
  662. <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span>
  663. <span class="p">{</span>
  664. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">helper</span><span class="p">(</span><span class="s1">&#39;url&#39;</span><span class="p">);</span>
  665. <span class="nv">$server_url</span> <span class="o">=</span> <span class="nx">site_url</span><span class="p">(</span><span class="s1">&#39;xmlrpc_server&#39;</span><span class="p">);</span>
  666. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpc&#39;</span><span class="p">);</span>
  667. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">server</span><span class="p">(</span><span class="nv">$server_url</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span>
  668. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">method</span><span class="p">(</span><span class="s1">&#39;Greetings&#39;</span><span class="p">);</span>
  669. <span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;How is it going?&#39;</span><span class="p">);</span>
  670. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span>
  671. <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">send_request</span><span class="p">())</span>
  672. <span class="p">{</span>
  673. <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">display_error</span><span class="p">();</span>
  674. <span class="p">}</span>
  675. <span class="k">else</span>
  676. <span class="p">{</span>
  677. <span class="k">echo</span> <span class="s1">&#39;&lt;pre&gt;&#39;</span><span class="p">;</span>
  678. <span class="nb">print_r</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">display_response</span><span class="p">());</span>
  679. <span class="k">echo</span> <span class="s1">&#39;&lt;/pre&gt;&#39;</span><span class="p">;</span>
  680. <span class="p">}</span>
  681. <span class="p">}</span>
  682. <span class="p">}</span>
  683. <span class="cp">?&gt;</span>
  684. </pre></div>
  685. </div>
  686. <div class="admonition note">
  687. <p class="first admonition-title">Note</p>
  688. <p class="last">In the above code we are using a “url helper”. You can find more
  689. information in the <a class="reference internal" href="../general/helpers.html"><span class="doc">Helpers Functions</span></a> page.</p>
  690. </div>
  691. </div>
  692. <div class="section" id="the-server">
  693. <h4><a class="toc-backref" href="#id16">The Server</a><a class="headerlink" href="#the-server" title="Permalink to this headline">¶</a></h4>
  694. <p>Using a text editor, create a controller called Xmlrpc_server.php. In
  695. it, place this code and save it to your application/controllers/
  696. folder:</p>
  697. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
  698. <span class="k">class</span> <span class="nc">Xmlrpc_server</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span>
  699. <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span>
  700. <span class="p">{</span>
  701. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpc&#39;</span><span class="p">);</span>
  702. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;xmlrpcs&#39;</span><span class="p">);</span>
  703. <span class="nv">$config</span><span class="p">[</span><span class="s1">&#39;functions&#39;</span><span class="p">][</span><span class="s1">&#39;Greetings&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;function&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Xmlrpc_server.process&#39;</span><span class="p">);</span>
  704. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpcs</span><span class="o">-&gt;</span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span>
  705. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpcs</span><span class="o">-&gt;</span><span class="na">serve</span><span class="p">();</span>
  706. <span class="p">}</span>
  707. <span class="k">public</span> <span class="k">function</span> <span class="nf">process</span><span class="p">(</span><span class="nv">$request</span><span class="p">)</span>
  708. <span class="p">{</span>
  709. <span class="nv">$parameters</span> <span class="o">=</span> <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">output_parameters</span><span class="p">();</span>
  710. <span class="nv">$response</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  711. <span class="k">array</span><span class="p">(</span>
  712. <span class="s1">&#39;you_said&#39;</span> <span class="o">=&gt;</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
  713. <span class="s1">&#39;i_respond&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Not bad at all.&#39;</span>
  714. <span class="p">),</span>
  715. <span class="s1">&#39;struct&#39;</span>
  716. <span class="p">);</span>
  717. <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">send_response</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span>
  718. <span class="p">}</span>
  719. <span class="p">}</span>
  720. </pre></div>
  721. </div>
  722. </div>
  723. <div class="section" id="try-it">
  724. <h4><a class="toc-backref" href="#id17">Try it!</a><a class="headerlink" href="#try-it" title="Permalink to this headline">¶</a></h4>
  725. <p>Now visit the your site using a URL similar to this:</p>
  726. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">example</span><span class="o">.</span><span class="nx">com</span><span class="o">/</span><span class="nx">index</span><span class="o">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">xmlrpc_client</span><span class="o">/</span>
  727. </pre></div>
  728. </div>
  729. <p>You should now see the message you sent to the server, and its response
  730. back to you.</p>
  731. <p>The client you created sends a message (“How’s is going?”) to the
  732. server, along with a request for the “Greetings” method. The Server
  733. receives the request and maps it to the <code class="docutils literal"><span class="pre">process()</span></code> method, where a
  734. response is sent back.</p>
  735. </div>
  736. </div>
  737. <div class="section" id="using-associative-arrays-in-a-request-parameter">
  738. <h3><a class="toc-backref" href="#id18">Using Associative Arrays In a Request Parameter</a><a class="headerlink" href="#using-associative-arrays-in-a-request-parameter" title="Permalink to this headline">¶</a></h3>
  739. <p>If you wish to use an associative array in your method parameters you
  740. will need to use a struct datatype:</p>
  741. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  742. <span class="k">array</span><span class="p">(</span>
  743. <span class="c1">// Param 0</span>
  744. <span class="k">array</span><span class="p">(</span><span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;John&#39;</span><span class="p">),</span>
  745. <span class="s1">&#39;struct&#39;</span>
  746. <span class="p">),</span>
  747. <span class="k">array</span><span class="p">(</span>
  748. <span class="c1">// Param 1</span>
  749. <span class="k">array</span><span class="p">(</span>
  750. <span class="s1">&#39;size&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;large&#39;</span><span class="p">,</span>
  751. <span class="s1">&#39;shape&#39;</span><span class="o">=&gt;</span><span class="s1">&#39;round&#39;</span>
  752. <span class="p">),</span>
  753. <span class="s1">&#39;struct&#39;</span>
  754. <span class="p">)</span>
  755. <span class="p">);</span>
  756. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span>
  757. </pre></div>
  758. </div>
  759. <p>You can retrieve the associative array when processing the request in
  760. the Server.</p>
  761. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$parameters</span> <span class="o">=</span> <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">output_parameters</span><span class="p">();</span>
  762. <span class="nv">$name</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;name&#39;</span><span class="p">];</span>
  763. <span class="nv">$size</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s1">&#39;size&#39;</span><span class="p">];</span>
  764. <span class="nv">$shape</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s1">&#39;shape&#39;</span><span class="p">];</span>
  765. </pre></div>
  766. </div>
  767. </div>
  768. <div class="section" id="id2">
  769. <h3><a class="toc-backref" href="#id19">Data Types</a><a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
  770. <p>According to the <a class="reference external" href="http://www.xmlrpc.com/spec">XML-RPC spec</a> there are
  771. seven types of values that you can send via XML-RPC:</p>
  772. <ul class="simple">
  773. <li><em>int</em> or <em>i4</em></li>
  774. <li><em>boolean</em></li>
  775. <li><em>string</em></li>
  776. <li><em>double</em></li>
  777. <li><em>dateTime.iso8601</em></li>
  778. <li><em>base64</em></li>
  779. <li><em>struct</em> (contains array of values)</li>
  780. <li><em>array</em> (contains array of values)</li>
  781. </ul>
  782. </div>
  783. </div>
  784. <div class="section" id="class-reference">
  785. <h2><a class="toc-backref" href="#id20">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2>
  786. <dl class="class">
  787. <dt id="CI_Xmlrpc">
  788. <em class="property">class </em><code class="descname">CI_Xmlrpc</code><a class="headerlink" href="#CI_Xmlrpc" title="Permalink to this definition">¶</a></dt>
  789. <dd><dl class="method">
  790. <dt id="CI_Xmlrpc::initialize">
  791. <code class="descname">initialize</code><span class="sig-paren">(</span><span class="optional">[</span><em>$config = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::initialize" title="Permalink to this definition">¶</a></dt>
  792. <dd><table class="docutils field-list" frame="void" rules="none">
  793. <col class="field-name" />
  794. <col class="field-body" />
  795. <tbody valign="top">
  796. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  797. <li><strong>$config</strong> (<em>array</em>) – Configuration data</li>
  798. </ul>
  799. </td>
  800. </tr>
  801. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p>
  802. </td>
  803. </tr>
  804. </tbody>
  805. </table>
  806. <p>Initializes the XML-RPC library. Accepts an associative array containing your settings.</p>
  807. </dd></dl>
  808. <dl class="method">
  809. <dt id="CI_Xmlrpc::server">
  810. <code class="descname">server</code><span class="sig-paren">(</span><em>$url</em><span class="optional">[</span>, <em>$port = 80</em><span class="optional">[</span>, <em>$proxy = FALSE</em><span class="optional">[</span>, <em>$proxy_port = 8080</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::server" title="Permalink to this definition">¶</a></dt>
  811. <dd><table class="docutils field-list" frame="void" rules="none">
  812. <col class="field-name" />
  813. <col class="field-body" />
  814. <tbody valign="top">
  815. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  816. <li><strong>$url</strong> (<em>string</em>) – XML-RPC server URL</li>
  817. <li><strong>$port</strong> (<em>int</em>) – Server port</li>
  818. <li><strong>$proxy</strong> (<em>string</em>) – Optional proxy</li>
  819. <li><strong>$proxy_port</strong> (<em>int</em>) – Proxy listening port</li>
  820. </ul>
  821. </td>
  822. </tr>
  823. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p>
  824. </td>
  825. </tr>
  826. </tbody>
  827. </table>
  828. <p>Sets the URL and port number of the server to which a request is to be sent:</p>
  829. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">server</span><span class="p">(</span><span class="s1">&#39;http://www.sometimes.com/pings.php&#39;</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span>
  830. </pre></div>
  831. </div>
  832. <p>Basic HTTP authentication is also supported, simply add it to the server URL:</p>
  833. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">server</span><span class="p">(</span><span class="s1">&#39;http://user:pass@localhost/&#39;</span><span class="p">,</span> <span class="mi">80</span><span class="p">);</span>
  834. </pre></div>
  835. </div>
  836. </dd></dl>
  837. <dl class="method">
  838. <dt id="CI_Xmlrpc::timeout">
  839. <code class="descname">timeout</code><span class="sig-paren">(</span><em>$seconds = 5</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::timeout" title="Permalink to this definition">¶</a></dt>
  840. <dd><table class="docutils field-list" frame="void" rules="none">
  841. <col class="field-name" />
  842. <col class="field-body" />
  843. <tbody valign="top">
  844. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  845. <li><strong>$seconds</strong> (<em>int</em>) – Timeout in seconds</li>
  846. </ul>
  847. </td>
  848. </tr>
  849. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p>
  850. </td>
  851. </tr>
  852. </tbody>
  853. </table>
  854. <p>Set a time out period (in seconds) after which the request will be canceled:</p>
  855. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">timeout</span><span class="p">(</span><span class="mi">6</span><span class="p">);</span>
  856. </pre></div>
  857. </div>
  858. <p>This timeout period will be used both for an initial connection to
  859. the remote server, as well as for getting a response from it.
  860. Make sure you set the timeout before calling <code class="docutils literal"><span class="pre">send_request()</span></code>.</p>
  861. </dd></dl>
  862. <dl class="method">
  863. <dt id="CI_Xmlrpc::method">
  864. <code class="descname">method</code><span class="sig-paren">(</span><em>$function</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::method" title="Permalink to this definition">¶</a></dt>
  865. <dd><table class="docutils field-list" frame="void" rules="none">
  866. <col class="field-name" />
  867. <col class="field-body" />
  868. <tbody valign="top">
  869. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  870. <li><strong>$function</strong> (<em>string</em>) – Method name</li>
  871. </ul>
  872. </td>
  873. </tr>
  874. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p>
  875. </td>
  876. </tr>
  877. </tbody>
  878. </table>
  879. <p>Sets the method that will be requested from the XML-RPC server:</p>
  880. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">method</span><span class="p">(</span><span class="s1">&#39;method&#39;</span><span class="p">);</span>
  881. </pre></div>
  882. </div>
  883. <p>Where method is the name of the method.</p>
  884. </dd></dl>
  885. <dl class="method">
  886. <dt id="CI_Xmlrpc::request">
  887. <code class="descname">request</code><span class="sig-paren">(</span><em>$incoming</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::request" title="Permalink to this definition">¶</a></dt>
  888. <dd><table class="docutils field-list" frame="void" rules="none">
  889. <col class="field-name" />
  890. <col class="field-body" />
  891. <tbody valign="top">
  892. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  893. <li><strong>$incoming</strong> (<em>array</em>) – Request data</li>
  894. </ul>
  895. </td>
  896. </tr>
  897. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p>
  898. </td>
  899. </tr>
  900. </tbody>
  901. </table>
  902. <p>Takes an array of data and builds request to be sent to XML-RPC server:</p>
  903. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$request</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">&#39;My Photoblog&#39;</span><span class="p">,</span> <span class="s1">&#39;string&#39;</span><span class="p">),</span> <span class="s1">&#39;http://www.yoursite.com/photoblog/&#39;</span><span class="p">);</span>
  904. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">request</span><span class="p">(</span><span class="nv">$request</span><span class="p">);</span>
  905. </pre></div>
  906. </div>
  907. </dd></dl>
  908. <dl class="method">
  909. <dt id="CI_Xmlrpc::send_request">
  910. <code class="descname">send_request</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::send_request" title="Permalink to this definition">¶</a></dt>
  911. <dd><table class="docutils field-list" frame="void" rules="none">
  912. <col class="field-name" />
  913. <col class="field-body" />
  914. <tbody valign="top">
  915. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td>
  916. </tr>
  917. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  918. </tr>
  919. </tbody>
  920. </table>
  921. <p>The request sending method. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.</p>
  922. </dd></dl>
  923. <dl class="method">
  924. <dt id="CI_Xmlrpc::display_error">
  925. <code class="descname">display_error</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::display_error" title="Permalink to this definition">¶</a></dt>
  926. <dd><table class="docutils field-list" frame="void" rules="none">
  927. <col class="field-name" />
  928. <col class="field-body" />
  929. <tbody valign="top">
  930. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Error message string</td>
  931. </tr>
  932. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
  933. </tr>
  934. </tbody>
  935. </table>
  936. <p>Returns an error message as a string if your request failed for some reason.</p>
  937. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">display_error</span><span class="p">();</span>
  938. </pre></div>
  939. </div>
  940. </dd></dl>
  941. <dl class="method">
  942. <dt id="CI_Xmlrpc::display_response">
  943. <code class="descname">display_response</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::display_response" title="Permalink to this definition">¶</a></dt>
  944. <dd><table class="docutils field-list" frame="void" rules="none">
  945. <col class="field-name" />
  946. <col class="field-body" />
  947. <tbody valign="top">
  948. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Response</td>
  949. </tr>
  950. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">mixed</td>
  951. </tr>
  952. </tbody>
  953. </table>
  954. <p>Returns the response from the remote server once request is received. The response will typically be an associative array.</p>
  955. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">display_response</span><span class="p">();</span>
  956. </pre></div>
  957. </div>
  958. </dd></dl>
  959. <dl class="method">
  960. <dt id="CI_Xmlrpc::send_error_message">
  961. <code class="descname">send_error_message</code><span class="sig-paren">(</span><em>$number</em>, <em>$message</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Xmlrpc::send_error_message" title="Permalink to this definition">¶</a></dt>
  962. <dd><table class="docutils field-list" frame="void" rules="none">
  963. <col class="field-name" />
  964. <col class="field-body" />
  965. <tbody valign="top">
  966. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  967. <li><strong>$number</strong> (<em>int</em>) – Error number</li>
  968. <li><strong>$message</strong> (<em>string</em>) – Error message</li>
  969. </ul>
  970. </td>
  971. </tr>
  972. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">XML_RPC_Response instance</p>
  973. </td>
  974. </tr>
  975. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">XML_RPC_Response</p>
  976. </td>
  977. </tr>
  978. </tbody>
  979. </table>
  980. <p>This method lets you send an error message from your server to the client.
  981. First parameter is the error number while the second parameter is the error message.</p>
  982. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">xmlrpc</span><span class="o">-&gt;</span><span class="na">send_error_message</span><span class="p">(</span><span class="mi">123</span><span class="p">,</span> <span class="s1">&#39;Requested data not available&#39;</span><span class="p">);</span>
  983. </pre></div>
  984. </div>
  985. </dd></dl>
  986. </dd></dl>
  987. </div>
  988. </div>
  989. </div>
  990. <footer>
  991. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  992. <a href="zip.html" class="btn btn-neutral float-right" title="Zip Encoding Class">Next <span class="fa fa-arrow-circle-right"></span></a>
  993. <a href="user_agent.html" class="btn btn-neutral" title="User Agent Class"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  994. </div>
  995. <hr/>
  996. <div role="contentinfo">
  997. <p>
  998. &copy; Copyright 2014 - 2019, British Columbia Institute of Technology.
  999. Last updated on Sep 19, 2019.
  1000. </p>
  1001. </div>
  1002. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  1003. </footer>
  1004. </div>
  1005. </div>
  1006. </section>
  1007. </div>
  1008. <script type="text/javascript">
  1009. var DOCUMENTATION_OPTIONS = {
  1010. URL_ROOT:'../',
  1011. VERSION:'3.1.11',
  1012. COLLAPSE_INDEX:false,
  1013. FILE_SUFFIX:'.html',
  1014. HAS_SOURCE: false
  1015. };
  1016. </script>
  1017. <script type="text/javascript" src="../_static/jquery.js"></script>
  1018. <script type="text/javascript" src="../_static/underscore.js"></script>
  1019. <script type="text/javascript" src="../_static/doctools.js"></script>
  1020. <script type="text/javascript" src="../_static/js/theme.js"></script>
  1021. <script type="text/javascript">
  1022. jQuery(function () {
  1023. SphinxRtdTheme.StickyNav.enable();
  1024. });
  1025. </script>
  1026. </body>
  1027. </html>