//            if($page["id"] == $page_id)
    //            {
    //                $page_access_token = $page["access_token"];
    //                break;
    //            }
    //        }
    //    }
    //    else
    //    {
    //        echo "AN ERROR OCCURED: could not get the access_token. Please verify the page ID ".$page_id." exists.";
    //    }
    //    $fb->setAccessToken($page_access_token);
    //
    //    // Now try to post on page's wall
    //    try{
    //        $message = array(
    //            'message' => "YOUR MESSAGE",
    //
    //        );
    //
    //        $result = $fb->api('/'.$page_id.'/feed','POST',$message);
    //        if($result){
    //            echo 'Successfully posted to Facebook Wall...';
    //        }
    //    }catch(FacebookApiException $e){
    //        echo $e->getMessage();
    //    }
} else {
    $fbloginurl = $fb->getLoginUrl(array('redirect-uri' => $returnurl, 'scope' => $permissions));
    echo '<a href="' . $fbloginurl . '">Login with Facebook</a>';
}
Ejemplo n.º 2
1
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
    try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');
    } catch (Facebook\FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}
// Login or logout url will be needed depending on current user state.
if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} else {
    $loginUrl = $facebook->getLoginUrl();
}
// This call will always work since we are fetching public data.
$naitik = $facebook->api('/naitik');
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>php-sdk</title>
    <style>
      body {
        font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
      }
      h1 a {
        text-decoration: none;
        color: #3b5998;
Ejemplo n.º 3
0
    var_dump($accessToken);
    echo "logged in";
    // Lets save fb_token for later authentication through saved $_SESSION
    //	$_SESSION['fb_token'] = $accessToken;
    try {
        // Returns a `Facebook\FacebookResponse` object
        $response = $fb->get('/me?fields=id,name,hometown,birthday,education,email,political,gender', $accessToken);
    } catch (Facebook\Exceptions\FacebookResponseException $e) {
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch (Facebook\Exceptions\FacebookSDKException $e) {
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }
    $user = $response->getGraphUser();
    echo 'Name: ' . $user['name'];
    echo '  id: ' . $user['id'];
    echo 'Education:' . $user['education'];
    echo 'email: ' . $user['email'];
    echo 'gender:' . $user['gender'];
    echo 'political; ' . $user['political'];
    echo 'Hometown: ' . $user['hometown'];
    // OR
    // echo 'Name: ' . $user->getName()	;
} else {
    $loginUrl = $fb->getLoginUrl(array('redirect_uri' => $fbconfig['appUrl']));
    header("Location: " . $loginUrl);
}
?>

Ejemplo n.º 4
0
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
//Home routes
Route::get('/', 'HomeController@index');
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
Route::get('post/user', 'Post\\PostController@user');
Route::get('category/user', 'Category\\CategoryController@user');
// Resource routes
Route::resource('category', 'Category\\CategoryController');
Route::resource('post', 'Post\\PostController');
// Password reset link request routes...
Route::get('password/email', 'Auth\\PasswordController@getEmail');
Route::post('password/email', 'Auth\\PasswordController@postEmail');
// Password reset routes...
Route::get('password/reset/{token}', 'Auth\\PasswordController@getReset');
Route::post('password/reset', 'Auth\\PasswordController@postReset');
//posts roots
Route::get('posts/{ids}', 'Post\\PostController@getPostsByCategoriesIds');
Route::get('login/fb', function () {
    $facebook = new Facebook\Facebook(Config::get('facebook'));
    $params = array('redirect_uri' => url('/login/fb/callback'), 'scope' => 'email');
    return Redirect::to($facebook->getLoginUrl($params));
});