2012-09-24 2 views
1

FOSFacebookBundle의 기본 구현은 클라이언트 측 흐름을 사용합니다. 나는 그것을 시도하고 그것을 작동합니다. 이제 서버 측 흐름을 구현해야합니다. 그럼 난 이렇게 : 액션이 같은 곳을 클릭FOSFacebookBundle에서 Facebook 서버 측 흐름을 사용하는 방법

하이퍼 링크 경로로 이동합니다 : 사용자가 다음 내 응용 프로그램 어디 조치로 다시 리디렉션 허용을 클릭

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

그것은 페이스 북으로 리디렉션됩니다, 클라이언트 측 동작을 처리하는 동일한 작업이

그리고 그것은 오류를 반환한다 : 를 활성 액세스 토큰은 현재 사용자

이 오류는이 라인에 의한 원인에 대한 정보를 조회하는 데 사용해야합니다 :

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

올바른 페이스 북 서버 측 흐름은 무엇입니까?

답변

0

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

이것은 서버 측 인증 흐름의 처음 세 단계입니다.

지금, 당신은뿐만 아니라 네 번째 단계을 할 필요가 : https://developers.facebook.com/docs/authentication/server-side/

관련 문제