I am developing an application where I am getting messages from conversations. Here is my code:
// facebook SDK startup
$fb = new FacebookFacebook([
'app_id' => '[my_app_id]',
'app_secret' => '[my_app_secret]',
'default_graph_version' => 'v2.4',
]);
$request = new FacebookFacebookRequest(
$session,
'GET',
'/{converation-id}',
array(
'fields' => 'gender'
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
var_dump($graphObject);
When I run this, i get this error:
Undefined variable: $session
I know that I haven’t initialized it but I am confused that what value do I have to assign to it or where do I need to connect this variable? Any suggestions?
2
Answers
This one is outdated.
For the newest versions you don’t need the
$session
variable. In the newer versions the$request->execute()
method is missing, too.Try something like this:
I got the same problem from FB SDK.
I have tried the code from Fabian, and it requests me to add the access token now.
And it works! I got the array result.