Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook API showing "The parameter app_id is required"

I have written correct AppID and APP secret but when I am running it on browser, Facebook is saying "The parameter app_id is required"

is there any error in this code, or I have missed some information ? here is the link www.smmstest.base.pk/

<?php 
require 'libs/facebook.php';
$facebook = new Facebook(array(
'appID' => '********************',
'secret' => '*************************',
'cookie' => true
));
   $user = $facebook->getUser();

   if ($user)
   {
      try
      {
         $user_profile = $facebook->api("/me");
      }
      catch (FacebookApiException $e)
      {
         error_log($e);
         $user = null;
      }      
   }

   if ($user)
   {
      $logoutUrl = $facebook->getLogoutUrl();
   }
   else
   {
      $loginUrl = $facebook->getLoginUrl();
   }
   ?>


<!doctype>
<html>
<head>
   <title>Fan page login</title>
</head>



   <body>

   <?php if ($user): ?>
      <a href="<?php echo $logoutUrl; ?>">Logout</a>
    <?php else: ?>
      <div>

        <a href="<?php echo $statusUrl; ?>">Check the login status</a>
      </div>
      <div>
        <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
      </div>
    <?php endif ?>

</body>

</html>
like image 235
Muhammad Ali Avatar asked Mar 01 '26 12:03

Muhammad Ali


1 Answers

https://github.com/facebook/facebook-php-sdk

require 'facebook-php-sdk/src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'YOUR_APP_ID',
  'secret' => 'YOUR_APP_SECRET',
));

Make sure you use the code from the latest PHP SDK. If you write "appId" correctly, it will add the parameter to every call to the Facebook Servers (which is "app_id" internally).

like image 113
andyrandy Avatar answered Mar 03 '26 02:03

andyrandy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!