Facebook connect api static url

Is there a way to use facebook connect api in a static way?

When we use facebook php sdk, the link or button to enter facebook is something like https://www.facebook.com/dialog/oauth ................. .

I want to exclude the inclusion of php sdk on each page, because this will cause some additional processing and server load at peak times.

I want to do a session check to find out if the user is logged in, checking, for example, if his user ID and username are stored in the session, and if not, display a static login button. then after logging into facebook, it gets into facebook-login.php, which will include php sdk facebook and process its data and store it in a session so that it stays on without php sdk on each page.

the url structure that I get with $ facebook-> getLoginUrl () is:

https://www.facebook.com/dialog/oauth?client_id= {MY_APP_KEY} & scope = {PERMISSIONS} & redirect_uri = {MY_SITE / facebook-login.php} & status = {A_32_CHAR_CODE_LIKE_MD5_MAYBE}

Final question: WHAT WAS THE URL IN THE LOGIN BUTTON?

+3
3

sdk - :

echo '<a href="' . $facebook->getLoginUrl( array('next'=>'http://mysite.com', 'req_perms' => 'email,read_stream,publish_stream')) . '">Connect to Facebook</a>';

URL- , .

0

. -, , , .

, API . , , , API Facebook . , .

, , , , ( , ).

:

  • Facebook : .

  • , : .

  • , ( ): .

  • : , .

. :

[fb_148195765253871_access_token] => 14819576525...
[fb_148195765253871_user_id] => 1536397056

( 148195765253871) - .

, , , , , SDK ( , SDK):

if (isset($_SESSION['fb' . YOUR_APP_ID . 'access_token'])) {
    // assume to user is logged in
    // and keep going
} else {
    require "facebook.php";
    $facebook = new Facebook(array(
        'appId'  => YOUR_APP_ID,
        'secret' => YOUR_APP_SECRET,
    ));

    // Make an API call to be sure the user is logged in
    // ie : that you have a valid access token
    $user = $facebook->getUser(); // User ID
    if ($user) {
        try {
            $user_profile = $facebook->api('/me');
        } catch (FacebookApiException $e) {
            $user = null;
        }
    }

    if ($user) {
        // The user is logged in for sure
    } else {
        // The user is not logged in for sure
        // Make him log in
        echo '<a href="' . $facebook->getLoginUrl() . '">Login with Facebook</a>';
    }
}

, !

0

.

Facebook, getLoginUrl, , , -.

So, in your heading is the link "Login with Facebook" to "facebook_login.php". This page lists the required calls from the SDK for getLoginUrl and the following HTML line is added.

<meta http-equiv="refresh" content="0;URL=<?=$helper->getLoginUrl(array('email', 'user_friends'));?>">

I tested this several times and it works.

FYI using Facebook SDK 4.0.

0
source

All Articles