i have making Facebook signup in php.when i cliked on Facebook login btn they show me this error "Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https://"
this is config.php file code
<?php
session_start();
require_once "Facebook/autoload.php";
$FB = new \Facebook\Facebook([
'app_id' => '571388466554956',
'app_secret' => '8381c3ba6df5f1d44ab8643be299e8dd',
'default_graph_version' => 'v2.10'
]);
$helper = $FB->getRedirectLoginHelper();
?>
OK The first step I think is to download the latest version of the Facebook SDK. Local tests showed this to me.
Related
I was implement login with Facebook in PHP It's perfect Works But i want if website open in mobile browser then redirect in Mobile Facebook Application if Not then mobile browser. How can Do ?
here some code
require_once __DIR__ . '/Facebook/autoload.php'; // download official fb sdk for php # https://github.com/facebook/php-graph-sdk
$fb = new Facebook\Facebook([
'app_id' => '*****************',
'app_secret' => '*******************',
'default_graph_version' => '***',
]);
$helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper2->getLoginUrl('URL', $permissions);
//here login with facebook button
Log in with Facebook!
This code redirect only facebook in browser.
Help me .
Thnakyou
I have on my generic sign in page a button that allows a user to log in via facebook. Also, i have the following code just prior to the user clicking the button so i can pass a redirect url to the callback after oauth2 authorization and redirect the logged in user somewhere.
<?php
session_start();
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
$fb = new \Facebook\Facebook([
'app_id' => 'appid',
'app_secret' => 'appsecret',
'default_graph_version' => 'v2.10',
]);
$helper = $fb->getRedirectLoginHelper();
$url=$helper->getLoginUrl("https://example.com/fblogin/callback");
$_SESSION['redirect']='somehurl';
setcookie("redirect","example.com");
header("Location: $url&scope=email");
Then I have
In my callback I have
<?php
session_start();
var_dump($_SESSION['redirect']); //null
var_dump($_COOKIE['redirect']); // null
I dont understand why but facebook is destroying my cookie and session data. Im using version 2.10
I am using PHP SDK for creating facebook login, which works fine but when I want to logout and I use getLogoutUrl method which returns logout url in this form:
https://www.facebook.com/logout?next=google.com&access_token=my_access_token
After I redirect to this page I get to the This page is not avalible page on FB and I am not logged out. Any idea what could be wrong ? or it will be SDK bug ? thanks.
I have created a article for facebook login logout with graph api with php. You can see the following code for logout from facebook with php. This is code for logout.php
session_start();
if(isset($_SESSION['fb_access_token'])){
require_once 'php-graph-sdk-5.5/src/Facebook/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => 'app-id', // Replace {app-id} with your app id
'app_secret' => 'app-id-secret',
'default_graph_version' => 'v2.4',
]);
$url = 'https://www.facebook.com/logout.php?next=your-website-return-url/&access_token='.$_SESSION['fb_access_token'];
session_destroy();
header('Location: '.$url);
}
If you need full source code then you can see this link
I'm using PHP Graph SDK to simplify logins to my site using Facebook.
The problem I'm getting is the error message after successfully logging into Facebook: "The redirect_uri URL must be absolute".
I've trawled the web (didn't find a solution) and added the redirect URL as "Valid OAuth redirect URI" at Facebook Dev Apps.enter image description here
But the error persists.
Here is the code:
$fb = new Facebook\Facebook([
'app_id' => FACEBOOK_APP_ID,
'app_secret' => FACEBOOK_APP_SECRET,
'default_graph_version' => 'v2.3',
]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['public_profile', 'email', 'user_location'];
$loginUrl = $helper->getLoginUrl('http://www.example.com/login_facebook.php', $permissions);
The full URL generated by the SDK is:
https://www.facebook.com/v2.3/dialog/oauth?client_id=9999999999999999&state=9999999999999999999999b&response_type=code&sdk=php-sdk-5.5.0&redirect_uri=http%3A%2F%2Fwww.example.com%2Flogin_facebook.php&scope=email
Your help is much appreciated. Thanks!
When a client removes the email from the info provided in facebook php sdk v5 how can I force Facebook to show the same menu as this image shows
I have a popup on my website, and this popup says that the user needs to give the email and after the popup it will redirect to Facebook login, the same as the first :
require_once"../facebook/Facebook-php-sdk-v5/autoload.php";
$fb = new Facebook\Facebook([
'app_id' => '****************',
'app_secret' => '********************************',
'default_graph_version' => 'v2.5',
]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['email', 'user_likes']; // optional
$loginUrl2 = $helper->getLoginUrl('http://example.com/facebook/fbcallback.php', $permissions);
I'v been looking all over the internet and I could not find anything that reprompts the same login panel after the client already logged in but rejected the email how can I do this?