Using Facebook Login in PHP

Asked

Viewed 648 times

1

I’m trying to log in with facebook, using SDK 3.2.3. I’m almost there, but the following message appears on the screen:

"Warning The parameter app_id is required".

Just follow my code:

   <?php
require_once ("facebook.php");

$config = array(
        'app_id' => 'yyyyyyyyyyyyy',
        'secret' => 'xxxxxxxxxxxxx',
        'allowSignedRequest' =>  false,
);

$facebook = new Facebook($config);
$uid = $facebook->getUser();

$params = array(
  'scope' => 'public_profile, user_friends, email',
  'redirect_uri' => 'https://www.petsmatch.com.br'
);

$loginUrl = $facebook->getLoginUrl($params);

if($user_id) {

      try {

        $user_profile = $facebook->api('/me','GET');
        echo "Name: " . $user_profile['name'];

      } catch(FacebookApiException $e) {
        $login_url = $facebook->getLoginUrl(); 
        echo 'Please <a href="' . $login_url . '">login.</a>';
        error_log($e->getType());
        error_log($e->getMessage());
      }   
    } else {
      $login_url = $facebook->getLoginUrl();
      echo 'Please <a href="' . $login_url . '">login.</a>';

    }
  • Have you changed your ways? Did you define this guy ('FACEBOK_SDK_V4_SRC_DIR', '/path/to/fb-php-sdk-v4/src/Facebook/'); with the path of the facebook files and set the appid and pass? FacebookSession::setDefaultApplication('YOUR_APP_ID', 'YOUR_APP_SECRET');

  • There is no "login button," it’s your html button/link, okay? Check out this tutorial: http://tableless.com.br/facebook-api-sdk-php-na-pratica-e-preview-de-howto approve your application/

  • Does anyone know what that message means? "The given URL is not allowed by the application configuration: One or more of the provided Urls are not allowed in the application settings. The URL must match the site URL or Canvas URL, or the domain must be a subdomain of one of the application domains."

  • Hello Gustavo, you’ve solved?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.