/* Request access tokens from twitter */ $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']); /* Save the access tokens. Normally these would be saved in a database for future use. */ $_SESSION['access_token'] = $access_token; $return_url = $_SESSION['return_url'] != "" ? $_SESSION['return_url'] : "/index.php"; /* Remove no longer needed request tokens */ unset($_SESSION['oauth_token']); unset($_SESSION['oauth_token_secret']); /* If HTTP response is 200 continue otherwise send to connect page to retry */ if (200 == $connection->http_code) { /* The user has been verified and the access tokens can be saved for future use */ $content = $connection->get('account/verify_credentials'); $DB = new dbConn(); $Member = new clsMembers($DB->getConnection()); $oauth_type = "twitter"; $result = $Member->getOauthMemberIdx($oauth_type, $content->id_str); if ($result['r'] == 'success') { $_SESSION['USER_IDX'] = $result['idx']; $_SESSION['USER_TYPE'] = $oauth_type; $_SESSION['USER_ID'] = $content->id_str; $_SESSION['USER_NAME'] = $content->name; $_SESSION['USER_IMAGE'] = $content->profile_image_url; $_SESSION['USER_AGREE'] = $result['policy_agree']; $c_idx = ""; $keyword = ""; if (!isset($_SESSION['favorite_cidx']) || $_SESSION['favorite_cidx'] != "") { $c_idx = $_SESSION['favorite_cidx']; $keyword = $_SESSION['favorite_keyword']; $_SESSION['favorite_cidx'] = ""; unset($_SESSION['favorite_cidx']); $_SESSION['favorite_keyword'] = "";
// Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array('appId' => FACEBOOK_APPID, 'secret' => FACEBOOK_SECRET)); $return_url = $_SESSION['return_url'] != "" ? $_SESSION['return_url'] : "/index.php"; $user = $facebook->getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } $DB = new dbConn(); $Member = new clsMembers($DB->getConnection()); $oauth_type = "facebook"; $result = $Member->getOauthMemberIdx($oauth_type, $user); if ($result['r'] == 'success') { $_SESSION['USER_IDX'] = $result['idx']; $_SESSION['USER_TYPE'] = $oauth_type; $_SESSION['USER_ID'] = $user; $_SESSION['USER_NAME'] = $user_profile['name']; $_SESSION['USER_IMAGE'] = "https://graph.facebook.com/" . $user . "/picture"; $_SESSION['USER_AGREE'] = $result['policy_agree']; $c_idx = ""; $keyword = ""; if (!isset($_SESSION['favorite_cidx']) || $_SESSION['favorite_cidx'] != "") { $c_idx = $_SESSION['favorite_cidx']; $keyword = $_SESSION['favorite_keyword']; $_SESSION['favorite_cidx'] = ""; unset($_SESSION['favorite_cidx']); $_SESSION['favorite_keyword'] = "";