Last active
August 29, 2015 14:16
-
-
Save grim13b/b2b300ff680bc35aac9b to your computer and use it in GitHub Desktop.
CakePHP 2.4.x + FacebookSDK用 飛んできた Facebook アクセストークンが正しいかどうかを確認するコードのメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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