3

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>
Muhammad Ali
  • 138
  • 1
  • 3
  • 10

2 Answers2

3

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).

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • there´s stuff between the closing body tag and the closing html tag - you should seriously remove the ads at least while developing. – andyrandy Mar 02 '14 at 13:29
  • the whole page includes a LOT of errors, better fix those before going anywhere near the Facebook stuff. The missing App-Id is another story, may be because of some wrong settings in App. You did set the correct App-Id and App-Secret, right? – andyrandy Mar 02 '14 at 13:32
  • ok :) facebook is working fine can you tell me that how can I login user to my App ? that says ALLOW and NOT ALLOW. – Muhammad Ali Mar 02 '14 at 21:52
  • that should be possible with your "Login with Facebook" link. it should redirect the user to the authorization. Take a look at the link i posted in the answer, if you scroll down you see the "Usage" part including login and stuff. – andyrandy Mar 02 '14 at 22:24
  • i see, there is an error: "App Not Setup: The developers of this app have not set up this app properly for Facebook Login" - well, i guess this covers the problem: http://stackoverflow.com/questions/21329250/the-developers-of-this-app-have-not-set-up-this-app-properly-for-facebook-login – andyrandy Mar 02 '14 at 22:27
0

fix it as

require 'libs/facebook.php';
$facebook = new Facebook(array(
'appID' => '********************',
'secret' => '*************************',
'cookie' => true

appID change to appId, it should work