07-17-2017, 07:35 AM
noticed in the above file our app id isn't being used in the javascript, so have adapted the script for for that.
<pre></pre>
<pre>
Code:
$db=DB::getInstance();
$settingsQ=$db->query("SELECT * FROM settings");
$settings=$settingsQ->first();
$appID=$settings->fbid;
$secret=$settings->fbsecret;
$version=$settings->graph_ver;
$callback=$settings->fbcallback;
?>
<script>
window.fbAsyncInit = function() {
FB.init({
//appId : '256684718065631',
appId : <?=$appID?>,
xfbml : true,
version : 'v2.7'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<?php
if(!isset($_SESSION)){session_start();}
require_once("src/Facebook/autoload.php");
$fb = new Facebook\Facebook([
'app_id' => $appID,
'app_secret' => $secret,
'default_graph_version' => $version,
]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['email']; // Optional permissions
$loginUrl = $helper->getLoginUrl($callback, $permissions);
echo '<a href="' . htmlspecialchars($loginUrl) . '"><img width="240" class="img-responsive pull-left" src="'
.TR_URL_ROOT.'users/images/facebook.png" alt="Facebook"/></a>';