I would like to get the city graph by facebook php sdk:
public static function getPublicGraphObject($Id)
{
$request = new FacebookRequest(null, 'GET', '/'.$Id);
$response = $request->execute();
$graphObject = $response->getGraphObject();
return $response->getGraphObject()->asArray();
}
because the city is public data, there is no need for session ? unfortunately I get this error Facebook\FacebookRequest::__construct() must be an instance of Facebook\FacebookSession, null given
? what should I do ?
To initialize the FacebookRequest
class, you need to pass it a FacebookSession
instance as first parameter, you can not simply pass NULL
instead.
If you do not have a current user logged in to your app (and therefor no user session), or want to make a request not on behalf of the current user, but simply “as” your app instead, create a new app session and pass that – the FacebookSession
class has a newAppSession
method for that purpose.