facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.17k stars 1.96k forks source link

Call to undefined function Facebook\\Facebook::api() #1062

Closed sureshsuthar555 closed 5 years ago

sureshsuthar555 commented 5 years ago

Hello I am trying to get list of all friends but when calling following script

require_once 'src/Facebook/autoload.php';

$fb = new Facebook\Facebook([ 'app_id' => 'xxxxxxxxxxxxxxxxx', 'app_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'default_graph_version' => 'v2.12', ]);

$friends = $fb->api('/me/friends');

it throw error "PHP Fatal error: Uncaught Error: Call to undefined method Facebook\Facebook::api()"

Can you please help to me to find out root cause of this error.

Also i want to publish a post on all friend wall. Which API Api will help me to do my job?

yguedidi commented 5 years ago

it looks like you wrot v4 code, please follow the v5 doc.