i trying integrate facebook authentication in php website.
i used below code:
<?php require '../facebook-php-sdk-master/src/facebook.php'; $app_id = 'some app id'; $app_secret = 'some secret'; $app_url = 'http://localhost/some app/'; $scope = 'email,publish_actions'; // init facebook sdk $facebook = new facebook(array( 'appid' => $app_id, 'secret' => $app_secret, )); // current user $user = $facebook->getuser(); // if user has not installed app, redirect them login dialog if ($user <> '0' && $user <> '') { /*if valid user id i.e. neither 0 nor blank nor null*/ try { $loginurl = $facebook->getloginurl(array( 'scope' => $scope, 'redirect_uri' => $app_url, )); die('<script>top.location.href="'.$facebook->getloginurl($params).'";</script>'); } catch (facebookapiexception $e) { /*sometimes shows user id if user in not logged in , results in oauth exception. in case set 0.*/ error_log($e); $user = '0'; } } else { echo 'user not found'; } ?> problem is:
though specifying , using correct app id, getting error message- the parameter app_id required.
i think facing similar problem- till getting “the parameter app_id required” error on facebook api login, there no accepted answer question.
please suggest if missing anything.
the parameter should appid you've set in new facebook(...);.
you can try override calling following after see if resolves issue:
$facebook->setappid('some app id');
Comments
Post a Comment