没有找到“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

?>

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', '.');