I have a token from facebook (from the graph explorer tool). I am using the PHP sdk. I created a session using the said token and called the FacebookSession::validate() method. It returned TRUE. I uploaded it in a test server and when I run it it says Session has expired. I debugged the token and the expiry should last 2 months.
When I try getting the user info (in the test server) it also works. Even the session info. It only throws a "session has expired" exception when I call the validate() method. Any ideas what I am doing wrong? Take note that this only happened after I uploaded it on a live server. The code on my local server and live are the same.
Here is a sample code. The appid and secret are already set by calling the setDefaultApplication() method.
<?php
\Facebook\FacebookSession::setDefaultApplication('app-id','app-secret');
$s = new \Facebook\FacebookSession('my-access-token');
$u = null;
try {
$fbr = new \Facebook\FacebookRequest($s, 'GET', '/1663246619?fields=id,first_name,last_name,gender,email,birthday,bio');
$u = $fbr->execute();
$i = $s->getSessionInfo();
var_dump($i->getProperty('is_valid'));
var_dump($s->validate());
} catch(\Exception $e) {
var_dump($e->getMessage());
}
var_dump($u->getGraphObject()->asArray());
Here is the response
bool(true)
string(50) "Session has expired, or is not valid for this app."
array(11) {
["id"]=>
string(10) "1663246619"
["email"]=>
string(22) "[email protected]"
["first_name"]=>
string(12) "Kapitanluffy"
["gender"]=>
string(6) "female"
["last_name"]=>
string(6) "Pirata"
["link"]=>
string(34) "http://www.facebook.com/1663246619"
["locale"]=>
string(5) "en_US"
["name"]=>
string(19) "Kapitanluffy Pirata"
["timezone"]=>
int(8)
["updated_time"]=>
string(24) "2014-12-06T23:47:48+0000"
["verified"]=>
bool(true)
}
other notes:
- The access token is for my app
- I am using facebook-php-sdk-v4 version 4.0.3