PEAR Articles
  Home arrow PEAR Articles arrow Page 4 - Using XML_RPC2 with PEAR
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PEAR ARTICLES

Using XML_RPC2 with PEAR
By: Chris Moyer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-07-30

    Table of Contents:
  • Using XML_RPC2 with PEAR
  • Creating an XML-RPC Client
  • Creating an XML-RPC Server
  • Cached Results

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using XML_RPC2 with PEAR - Cached Results


    (Page 4 of 4 )

    Another great feature of the XML_RPC2 library is the ability to cache results. If your site makes heavy use of a remote API, and the results don't change very often, this can be a great performance gain.

    To enable caching, with all the default caching options, we simply change the first two lines of our client example to include CachedClient and instantiate a CachedClient instance instead of a regular client instance:

    require('XML/RPC2/CachedClient.php');


    $client = XML_RPC2_CachedClient::create(

    'http://localhost/xml_rpc_server.php',

    array('debug' => true, 'prefix' => 'time.'));

    If you reload the page a few times, you'll see that the server transactions only occur on the first call. Caching on the server side is equally simple, substituting CachedServer for Server.

    Additionally, you can pass some options to control caching on the client or server end:

    $options = array(

    'cacheOptions' =>

    array(

    'cacheDir' => '/tmp', // Where to store cache files

    'lifetime' => 3600, // How long to store cache


    // Whether to require a parameter to enable the cache

    'cacheByDefault' => true,

    )

    )

    In Conclusion

    While XML-RPC is not the only option for talking across the web to other services, it is an excellent one. It is light-weight, simple to consume from many languages and platforms, and has been proven effective in many situations. XML_RPC2 in PEAR makes it an even more viable solution for your PHP website, abstracting away all the details and presenting a simple, easy to understand interface. The next time you need to make or consume a web service, keep XML_RPC2 in mind!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    PEAR ARTICLES ARTICLES

    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning
    - Using XML_RPC2 with PEAR
    - Using Web Service APIs (Amazon and Yahoo!) w...
    - Database Abstraction with MDB2 from PEAR





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek