duanjia6959 2015-09-02 17:56
浏览 83

没有找到“Facebook \\ Facebook”类

I am new to PHP. I have read a lot about this error, but can't get past this what should be a no-brainer. This is the code I have.

<?PHP

$page_id = $_POST["page_id"];
$app_id = $_POST["app_id"];
$app_secret = $_POST["app_secret"];
$access_token = $_POST["access_token"];

define('FACEBOOK_SDK_V4_SRC_DIR', '/src/Facebook/');
require __DIR__ . '/autoload.php';

define ('APP_ID',$app_id);
define ('APP_SECRET',$app_secret);

//
// Code runs to here
//

$fb = new Facebook\Facebook([
  'app_id' => '{APP_ID}',
  'app_secret' => '{APP_SECRET}',
  'default_graph_version' => 'v2.4',
  ]);

//
// Code fails with this error mesage
//

Fatal error: Class 'Facebook\\Facebook' not found

?>
  • 写回答

1条回答 默认 最新

  • doudi8298 2015-09-02 18:08
    关注

    From your code it seems that your script and the autoload.php file are in the same folder (since you're using require __DIR__ . '/autoload.php';). In this case, you should also set the FACEBOOK_SDK_V4_SRC_DIR constant to the same folder.

    Replace your definition with this:

    define('FACEBOOK_SDK_V4_SRC_DIR', '.');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计