Skip to content

Instantly share code, notes, and snippets.

@grim13b
Last active August 29, 2015 14:16
Show Gist options
  • Save grim13b/b2b300ff680bc35aac9b to your computer and use it in GitHub Desktop.
Save grim13b/b2b300ff680bc35aac9b to your computer and use it in GitHub Desktop.
CakePHP 2.4.x + FacebookSDK用 飛んできた Facebook アクセストークンが正しいかどうかを確認するコードのメモ
<?php
Class FacebookTokenVerifyExample {
public function verifyToken($token) {
$appId = Configure::read('fb_app_id');
$appSecret = Configure::read('fb_app_secret');
FacebookSession::setDefaultApplication($appId, $appSecret);
$facebookSession = FacebookSession::newAppSession();
$request = new FacebookRequest(
$facebookSession,
'GET',
"/debug_token?input_token=$token");
$response = $request->execute();
$graphSession = $response->getGraphObject('Facebook\GraphSessionInfo');
return $graphSession->isValid();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment