My WebApp (using facebook login) logs me out of the system

I use facebook login to my website

window.fbAsyncInit = function() {

    // init the FB JS SDK
    FB.init({
      appId      : 'XXX', // App ID from the App Dashboard
      channelUrl : 'XXX/channel.php', // Channel File for x-domain communication
      cookie     : true, // set sessions cookies to allow your server to access the session?
      frictionlessRequests: true
    });

};

The problem is that I go to my site every ~ 10-20 minutes. On the site this is what the reboot is, and I logged in again. I think the cookies are somehow deleted.

Is there any way to extend this cookie?

My login is as follows:

FB.login(function(response) {}, {scope:'publish_actions'});

Update:

This part of my script is called when the user logs in for the first time:

// triggers on first login
if (isset($_GET['first_login'])) {
    if ($me) {
        $facebook->setExtendedAccessToken();
        $friends = $facebook->api('/me/friends');
        $friends = $friends['data'];
        if (!empty($friends)) {
            // sql

        }
        $permissions = $facebook->api("/me/permissions");

        if( array_key_exists('publish_actions', $permissions['data'][0]) ) {
            $attachment = array(
                    'message' => 'XXX',
                    'name' => 'XXX - App',
                    'link' => 'XXX',
                    'description' => 'XXX',
                    'picture'=> 'XXX',
                    'access_token' =>  $facebook->getAccessToken()
            );
            $facebook->api('/'.$facebook->getUser().'/feed', 'POST', $attachment);

            // sql
        }
        header('Location: http:/xxx');
    }
}

But I get an error

Fatal error: OAuthException could not be thrown: (# 1) An error occurred while creating the share received in / facebook / base _facebook.php on line 1254

What caused $facebook->api('/'.$facebook->getUser().'/feed', 'POST', $attachment);

When I remove an attribute linkfrom mine $attachment, it works. Is the link attribute prohibited or something else?

0
1
+1

All Articles