function getFacebookFans() { global $coll; $query = $coll->findOne(array('username' => $_SESSION["username"])); if (isset($query['facebook_page'])) { if (isset($query['facebook_access_token'])) { $access_token = $query['facebook_access_token']; } else { callFacebookAuth(); } //Run fql and opengraph queries $fql_query_page = json_decode(getFacebookPageDetails($access_token, $query['facebook_page']['facebook_page_id']), true); //Check for errors if (isset($fql_query_page['error'])) { if ($fql_query_page['error']['type'] == "OAuthException") { callFacebookAuth(); } else { return "Other Facebook authentication error has happened"; } } else { return $fql_query_page['data'][0]['fql_result_set'][0]['fan_count']; } } }
include_once "modules/config.php"; if (!loggedIn()) { header('Location: login.php'); exit; } else { $query = $coll->findOne(array('username' => $_SESSION["username"])); if (isset($query['facebook_access_token'])) { $access_token = $query['facebook_access_token']; } else { callFacebookAuth(); } if (isset($query['facebook_page'])) { foreach ($query['facebook_page'] as $obj_page) { //Run fql and opengraph queries $fql_query_page = json_decode(getFacebookPageDetails($access_token, $obj_page['facebook_page_id']), true); $opengraph_query_page = json_decode(getFacebookPageFeed($access_token, $obj_page['facebook_page_id']), true); //Check for errors if ($fql_query_page['error']) { if ($fql_query_page['error']['type'] == "OAuthException") { callFacebookAuth(); } else { echo "Other Facebook authentication error has happened"; } } echo 'Page Details:'; echo '<br>'; echo '<pre>'; print_r($fql_query_page); echo '</pre>'; echo '<br><br>';