Using Drupal as client of a web service
Drupal has specific functions that can help with communicating with a web service, and handling JSON input.
Drupal 7 has the following functions:


drupal_http_request() is the function to make a HTTP request to a remote site, and it handles GET, POST, PUT or any other HTTP requests; it also handles redirects.
drupal_http_build_query() transform an array in an rawurlencode()-d string.
drupal_json_decode() decodes a JSON string in PHP code.
drupal_json_encode() encode a PHP variable into a string that is handled by JSON.


With those functions you can write your own custom module to make requests to a site implementing a web service.

If there are some restrictions about the number of requests that can be done to the web server, you can use the Drupal functions to cache the result obtained from the web server:


cache_get(), to get the data saved in the cache
cache_set(), to save the data in the cache


To notice that Drupal supports more than one cache bin, and modules can use their own cache bins, when necessary.
Drupal supports also cache items that are automatically removed at the successive cache swipe (see the description for the CACHE_TEMPORARY constant). Implementing hook_flush_caches(), the modules allow to the administrator users to clean the cache used by the module when the "Clear" button on the "Performance" page is clicked, or any times a module calls drupal_flush_all_caches().

In Drupal 7, cache data for frequently used data are associated with a static variable handled with drupal_static(). When the data is really frequently used when outputting the same page, code similar to the following one is used:

  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['implementations'] = &amp;drupal_static(__FUNCTION__);
  }
  $implementations = &amp;$drupal_static_fast['implementations'];

  // …

  // Fetch implementations from cache.
  if (empty($implementations)) {
    $implementations = cache_get('module_implements', 'cache_bootstrap');
    if ($implementations === FALSE) {
      $implementations = array();
    }
    else {
      $implementations = $implementations-&gt;data;
    }
  }


The code is part of module_implements().