2012-09-24 28 views
1

FOSFacebookBundle的默認實現是使用客戶端流程。我已經嘗試過,它的工作原理。現在我需要實現服務器端流程。然後,我這樣做:點擊後如何使用Facebook服務器端流程與FOSFacebookBundle

超鏈接會去的路線,其中的動作是這樣的:

$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); 

它被重定向到Facebook的,當用戶點擊允許,然後重定向回我的應用程序,其中的動作是處理客戶端的動作相同的動作

並返回錯誤: 的主動訪問令牌必須用於查詢當前用戶

此錯誤是這行的原因信息:

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

什麼是使用facebook服務器端流程的正確實現?

回答

相關問題