You are here

function fbconnect_graph_query in Facebook Connect 7.2

Same name and namespace in other branches
  1. 8.2 fbconnect.module \fbconnect_graph_query()
  2. 6.2 fbconnect.module \fbconnect_graph_query()

Make Graph Query.

Parameters

string $path:

Return value

array

2 calls to fbconnect_graph_query()
FbconnectTestCase::_createFbTestUser in tests/fbconnect.test
fbconnect_test_fb_session in tests/fbconnect_test.module

File

./fbconnect.module, line 398
Facebook Connect API module.

Code

function fbconnect_graph_query($path, $params = array(), $method = 'GET', $use_app_token = FALSE) {
  if ($use_app_token) {
    $conf = fbconnect_get_config();
    $fb_session = FacebookSession::newAppSession($conf['app_id'], $conf['secret_api_key']);
  }
  else {
    $fb_session = facebook_client_session();
  }
  if ($fb_session && $path) {
    try {
      try {
        $me = (new FacebookRequest($fb_session, $method, $path))
          ->execute()
          ->getGraphObject(GraphUser::className());
        return $me;
      } catch (\Exception $e) {
        drupal_set_message($e
          ->getMessage(), 'error');
        throw $e;
      }
    } catch (Exception $e) {
      $msg = 'Exception thrown while using fbconnect_graph_query : @code';
      watchdog('fbconnect', $msg, array(
        '@code' => $e
          ->getMessage(),
      ), WATCHDOG_WARNING);
    }
  }
}