Drupal has specific functions that can help with communicating with a web service, and handling JSON input.
Drupal 7 has the following functions:
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:
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'] = &drupal_static(__FUNCTION__);
}
$implementations = &$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->data;
}
}
The code is part of module_implements().