Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

php - 'Class 'FacebookFacebook' not found" Facebook SDK error

Well I am new to facebook sdk. I have being following the guideline and performing the steps as written.. but I am getting this error and I dont know why?

 Fatal error: Class 'FacebookFacebook' not found in C:wampwwwindex.php on line 134

The error line code is:

<?php 
$fb = new FacebookFacebook([
  'app_id' => '{app-id}',
  'app_secret' => '{app-secret}',
  'default_graph_version' => 'v2.2',
  ]);
?>

This is not something I have made up, this is exactly the same code mentioned in facebook guideline! What should I do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to include the autoloader first to get access to the service methods and classes (as said in the PHP SDK Documentation for Facebook API. You are trying to use a namespaced class FacebookFacebook, to use its methods, but you don't have the class in the PHP file.

require_once 'src/Facebook/autoload.php';
//Create the Facebook service
$fb = new FacebookFacebook ([
    'app_id' => '-----------------',
    'app_secret' => '--------------------',
    'default_graph_version' => 'v2.4'
    ]);

Somewhere in your directory (if you installed the Facebook PHP SDK) correctly, you will find the autoload.php file which automatically requires .php files that you need to use the services and methods.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...