0
클라이언트가 facebook 사용자 ID (예 : myapi/get_user/123
)를 제공하고 API에서 이름, 생일 등과 같은 사용자의 공개 정보를 검색해야하는 편안한 API를 개발하고 있습니다. 끝난.맞춤 API의 FB 액세스 토큰을 처리하는 모범 사례
현재 코드 :
$fb = new Facebook\Facebook([
'app_id' => $fbSettings['app_id'],
'app_secret' => $fbSettings['app_secret'],
'default_graph_version' => $fbSettings['default_graph_version']
]);
$token = 'EAAD...';
try {
// Returns a `Facebook\FacebookResponse` object
$fbResponse = $fb->get('/' . $request->getAttribute('id') . '?fields=link, name, birthday', $token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
return $response->withStatus(500)->withJson(['msg' => $e->getMessage()]);
exit;
}
$user = $fbResponse->getGraphUser();
return $response->withJson($user);
내 문제는 내가 액세스 토큰을 처리 할 수있는 가장 좋은 방법이 무엇인지 모르는입니다. 클라이언트가 토큰을 제공해야합니까? 이 경우 같은 요청 (예 : myapi/get_user/123?token=ABC123
)에서 매개 변수로 전달되거나 다른 API 호출 (myapi/register_token/ABC123
)이 무국적이라는 원칙을 위반해야합니다.
액세스 토큰을 처리하는 가장 좋은 방법 (또는 모범 사례)을 찾고 있습니다.
있습니까? –