You are here

function fb_http in Drupal for Facebook 7.4

Wrapper around drupal_http_request() which detects error codes.

4 calls to fb_http()
fb_graph in ./fb.module
Read from facebook's graph.
fb_graph_batch in ./fb.module
Read from facebook's graph in batch mode. Allows a single request to facebook to return data from multiple graph nodes.
fb_graph_delete in ./fb.module
Delete from facebook's graph.
fb_graph_post in ./fb.module
Write to facebook's graph.

File

./fb.module, line 1127

Code

function fb_http($url, array $options = array()) {
  try {
    $response = drupal_http_request($url, $options);
    return fb_http_parse_response($response);
  } catch (Exception $e) {
    if (!empty($e->fb_code) && $e->fb_code == 190) {

      //dpm(debug_backtrace(), __FUNCTION__);

      // Token has expired.
      $url_data = drupal_parse_url($url);

      //dpm($url_data, __FUNCTION__);
      if ($token = $url_data['query']['access_token']) {
        fb_token_invalid($token);
      }
    }
    else {
      fb_log_exception($e, t('Failed to query %url.', array(
        '%url' => $url,
        '%code' => $e->fb_code,
      )));
      fb_log_exception($e, t('Failed to query %url. <pre>!debug</pre>', array(
        '%url' => $url,
        '%code' => $e->fb_code,
        '!debug' => print_r($options, 1),
      )));
    }
    throw $e;
  }
}