質問

The default implementation of FOSFacebookBundle is using client-side flow. I've tried it and it works. Now I need to implement the server-side flow. Then I do this:

Hyperlink when clicked will go to a route where the Action is like this:

$client_id = $this->container->getParameter('fos_facebook.app_id');
$redirect_uri = urlencode($this->generateUrl('_security_check', array(), true));
$scope = implode(',', $this->container->getParameter('fos_facebook.permissions'));
$state = md5(uniqid(rand(), TRUE)); //CSRF protection
$this->getRequest()->getSession()->set('facebook_state', $state);

$oauthUrl = 'https://www.facebook.com/dialog/oauth?client_id='.$client_id.'&redirect_uri='.$redirect_uri.'&scope='.$scope.'&state='.$state;
return $this->redirect($oauthUrl);

It is redirected to Facebook, when user click allow then redirected back to my application where the action is the same action which handle the client-side action

And it return error: An active access token must be used to query information about the current user

This error is cause by this line:

$me = $this->fbapi->api('/me');

What is the correct implementation using facebook server-side flow?

役に立ちましたか?

解決

It is redirected to Facebook, when user click allow then redirected back to my application where the action is the same action which handle the client-side action

That’s the first three steps of the server-side Auth flow taken care of.

Now, you have to do the fourth step as well: https://developers.facebook.com/docs/authentication/server-side/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top