<?php include '../../../src/Facebook/FacebookHandler.php'; $facebook = new FacebookHandler(); $facebook->connect(); $return = array(); if (isset($_SESSION) && isset($_SESSION['fb_token'])) { $facebook->setFbToken($_SESSION['fb_token']); } else { $fbAuth = $facebook->getSessionAuth(); if ($fbAuth) { $facebook->setAccessToken($fbAuth); $return['token'] = $facebook->getAccessToken; } else { $loginUrl = $facebook->getRedirectUrl(); $redirect = "Location: " . $loginUrl; header($redirect); exit; } } $return['source'] = $_POST['image']; $return['message'] = $_POST['text']; echo json_encode($return); exit;
<?php include '../../src/Facebook/FacebookHandler.php'; ini_set("display_errors", 1); $facebook = new FacebookHandler(); $facebook->connect(); if (isset($_SESSION) && isset($_SESSION['fb_token'])) { $facebook->setFbToken($_SESSION['fb_token']); } else { $fbAuth = $facebook->getSessionAuth(); if ($fbAuth) { $facebook->setAccessToken($fbAuth); } else { $loginUrl = $facebook->getRedirectUrl(); $redirect = "Location: " . $loginUrl; header($redirect); exit; } } $details = $facebook->getFacebookDetails(); $birthday = date("Y-m-d", strtotime($details->birthday)); $return = array('id' => $details->id, 'fname' => $details->first_name, 'lname' => $details->last_name, 'age' => $details->age_range->min, 'email' => $details->email, 'location' => $details->location->name, 'gender' => $details->gender, 'birthday' => $birthday); $_SESSION['return'] = $return; $userInt = $facebook->getUserInterests(); $interests = array(); foreach ($userInt->data as $ui) { $temp = array('category' => $ui->category, 'name' => $ui->name, 'interest_id' => $ui->id); array_push($interests, $temp); } $_SESSION['interests'] = json_encode($interests); header('Location: http://' . $_SERVER['HTTP_HOST'] . '/registration');