You are here

function _sharedblocks_fetch_url in Shared Blocks 7.2

Actually retrieve the block info from a URL. Used when refreshing a cached block, and when the block is first subscribed, to validate the URL.

Parameters

string $url Shared Blocks URL on the remote site:

Return value

mixed Array of data if successful, FALSE otherwise.

2 calls to _sharedblocks_fetch_url()
sharedblocks_cache_refresh in ./sharedblocks.subscribe.inc
Refresh the cached content for the given shared block. The updated data is returned.
sharedblocks_element_validate_url in ./sharedblocks.module

File

./sharedblocks.subscribe.inc, line 68
Subscribe block page callbacks for the sharedblocks module.

Code

function _sharedblocks_fetch_url($url) {
  $data = FALSE;
  $response = drupal_http_request($url);
  if (isset($response->error)) {
    watchdog('sharedblocks', 'Error @code @error when attempting to fetch @url.', array(
      '@code' => $response->code,
      '@error' => $response->error,
      '@url' => $url,
    ));
  }
  else {
    $data = drupal_json_decode($response->data);
    if (!is_array($data)) {
      watchdog('sharedblocks', 'Unable to parse block data from @url.', array(
        '@url' => $url,
      ));
      $data = FALSE;
    }
  }
  return $data;
}