php - Using Facebook graph API, error when trying to get friends list -
i using php facebook php sdk
my code:
session_start(); require_once __dir__ . '/vendor/autoload.php'; use facebook\facebookrequest; $fb = new facebook\facebook([ 'app_id' => 'xxxx', 'app_secret' => 'xxxx', 'default_graph_version' => 'v2.5', ]);
i able log in facebook account, having trouble getting user friends list.
this how i'm doing it:
//get friends list $session = $_session['facebook_access_token']; $request = new facebookrequest( $session, 'get', '/me/taggable_friends', array( 'fields' => 'name,picture' ) );
i took code facebook graph explorer , on there working perfectly.
i getting following error:
catchable fatal error: argument 1 passed
facebook\facebookrequest::__construct()
must instance offacebook\facebookapp
,string
given, called in/applications/xampp/xamppfiles/htdocs/project/index.php
on line 76 , defined in/applications/xampp/xamppfiles/htdocs/project/vendor/facebook/php-sdk-v4/src/facebook/facebookrequest.php
on line 97
what doing wrong, , ok have done $session variable?
you have use app instance, right using string error message tells you. here´s relevant part of official docs, example code:
https://developers.facebook.com/docs/php/facebookrequest/5.0.0
i suggest upgrading v5.0 of php sdk, comes same server requirements anyway.
Comments
Post a Comment