'Class'Facebook\Facebook'not found“ Facebook SDK错误 [英] 'Class 'Facebook\Facebook' not found" Facebook SDK error

查看:169
本文介绍了'Class'Facebook\Facebook'not found“ Facebook SDK错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,我是facebook sdk的新手。我正在按照指导方针执行步骤,但我收到这个错误,我不知道为什么?

 致命错误:类别Facebook\Facebook未找到C:\wamp\www\index.php在线134 

错误代码是:

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

这不是我已经弥补的,这是在Facebook指南中提到的完全相同的代码!我该怎么办?

解决方案

首先需要包含 autoloader 以访问服务方法和类(如PHP SDK文档中针对 Facebook API所述)您正在尝试使用命名空间的类 Facebook\Facebook ,使用它的方法,但你没有PHP文件中的类。

  require_once'src /Facebook/autoload.php'; 
//创建Facebook服务
$ fb = new Facebook\Facebook([
'app_id'=>'------- ----------',
'app_secret'=>'--------------------',
' default_graph_version'=>'v2.4'
]);

(如果您安装了Facebook PHP SDK),您会发现 autoload.php 文件自动需要 .php您需要使用服务和方法的文件。


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 'Facebook\Facebook' not found in C:\wamp\www\index.php on line 134

The error line code is:

<?php 
$fb = new Facebook\Facebook([
  '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?

解决方案

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 Facebook\Facebook, 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 Facebook\Facebook ([
    '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.

这篇关于'Class'Facebook\Facebook'not found“ Facebook SDK错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆