PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 11, 2022

[FIXED] Facebook API showing "The parameter app_id is required"

 February 11, 2022     facebook-php-sdk, php     No comments   

Issue

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>

Solution

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



Answered By - andyrandy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing