"facebook.com" missing from login page URL - facebook

I can not login with facebook from any applications, including from mine. This is caused by the lack of "facebook.com" in login page URL. When we click the login button, the URL should be
https://www.facebook.com/login.php?skip_api_login=1&api_key=XXX....
but in my case :
https://www./login.php?skip_api_login=1&api_key=XXX.. (without "facebook.com")
So, the web page can not display anything. It just happened today, everything was normal yesterday. I have try facebook basic example code and the problem still same. Here's the code :
<?php
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => '137737616434442',
'secret' => 'XXX',
'baseurl' => 'http://localhost/facebookconnect/login/example.php',
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl(array( 'next' => 'http://localhost/facebookconnect/login/example.php' ));
session_destroy();
} else {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'email,user_birthday,friends_birthday,publish_stream,user_location,friends_location,user_work_history,user_likes,friends_work_history,user_about_me,friends_about_me,user_hometown',
'redirect_uri' => 'http://localhost/facebookconnect/login/example.php'));
}
$naitik = $facebook->api('/naitik');
?>
Any help would be greatly appreciated, thank you

I think it's Facebook app problem. Looks like the problem occurs everywhere.

I restart my connection and, everything is back to normal. Looks weird, but it works.

My Facebook page is missing today (August 28, 2013) too! It was there at midnight last night but won't load today! My Outlook/Hotmail won't work either. Loads but won't open anything. I think it's been hijacked after a friend's hotmail was hijacked. This computer is going to the hospital tomorrow. Until then it is being unplugged from the internet.

Related

Endless redirect loop in Facebook canvas application

I have tried to search this, but have found no answers. I have [had] a working application on Facebook up until yesterday, then all hell broke loose and it simply doesn't come up. Please keep in mind, nothing changed on my end. The application has been running for over a year with no problems.
Yesterday, I accessed the application like normal and got an additional permission request for access to my friends list. Strange, again because I have made no changes to the code or the configuration on FB. I accepted the request and now instead of the application coming up, it simply goes into an endless oauth login redirect loop. In fact it doesn't even look like it ever calls my application url as I cannot debug it (it never breaks on the code)
I guess my question is, does anyone know of something changing recently on FB to cause this?
The application can be found at: https://apps.facebook.com/myworkoutlog
And as I wrote this, the app came up, but after closing the browser and starting again, back into the endless loop. Any help would be great. If you need additional information, please just ask.
Edit:
I finally got it into debug and it breaks when I try to get an access_token using a verification code: (OAuthException - #100) Invalid verification code format.
Try this it works for me ;)
include_once "facebook.php";
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxx',
'cookie' => true
));
$fb_user = $facebook->getUser();
if($fb_user){
if(isset($_GET['code']) && isset($fb_user)){
$fbAppNs = 'appOnFacebookNameSpace';
$facebookAppUrl = 'https://apps.facebook.com/'.$fbAppNs;
header("Location: " . $facebookAppUrl);
exit;
}
try{
$user_profile = $facebook->api('/me');
$smarty->assign('name', $user_profile['first_name'].' '.$user_profile['last_name']);
$smarty->assign('email', $user_profile['email']);
}catch(FacebookApiException $e){
error_log($e);
$user = NULL;
}
}else{
$loginData = array(
'scope' => 'email,publish_stream',
'canvas' => 1,
'fbconnect' => 0,
'redirect_uri' => $siteConfigs['WEBSITE_URL'].'fblead/'
);
$loginUrl = $facebook->getLoginUrl($loginData);
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
exit;
}

facebook php sdk automatically logs out user

I am trying to integrate facebook login in my website.
I am facing a weird problem wherein the user keeps getting logged out almost every 10 minutes from my website, although he remains logged in to facebook:
I don't have much clue about the cause of the error, but this might help. I had some error in my javascript code and since during that time, javascript was not being executed, I somehow remained logged in.
For implementing facebook login i am using geloginUrl and getLogoutUrl functions in php, I have added some code to post on friends' wall etc in javascript as well.
That is all the relevant information according to me.
Let me know, if any additional details might be required to answer this question correctly.
This is what my code looks like:
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
$user = 0;
}
}
if ($user) {
setcookie('uid', $user, time()+36000, '/', 'mywebsite.com');
setcookie('uname', $user_profile['name'], time()+36000, '/', 'mywebsite.com');
} else {
setcookie('uid', $user, time()+36000, '/', 'mywebsite.com');
setcookie('uname', $user_profile['name'], time()+36000, '/', 'mywebsite.com');
}
$loginUrlParams = array(
'scope' => 'email,user_activities,friends_activities,friends_interests,user_interests',
'redirect_uri' => 'http://mywebsite.com/getfbToken.php'
);
$loginUrl = "";
$logoutUrl = "";
$logoutUrlParams = array( 'next' => 'http://mywebsite.com/logout.php' );
// getting login url from facebook if user is invalid
if (!$user)
$loginUrl = $facebook->getLoginUrl($loginUrlParams);
else
$logoutUrl = $facebook->getLogoutUrl($logoutUrlParams);

Facebook application : Doesn't redirect to OAuth in an iFrame

I am currently developing a facebook application using the php sdk and the js sdk. (I need both of them)
When a user has not yet authorized the application and loads the canvas page (https://apps.facebook.com/app_name/), nothing happens, he just gets a blank page with the facebook bar on top.
But if he loads the direct url of the application (https://my_app.mydomain.com), it works fine and he is redirected to the OAuth Dialog. If he authorizes the application, he is then redirected to https://apps.facebook.com/app_name/ and the iframe loads correctly.
If the user has already authorized the applications, both links are working (https://apps.facebook.com/app_name/ and https://my_app.mydomain.com).
Here is my authentication code :
<?php
require 'php-sdk/facebook.php';
$facebook = new Facebook(array(
'appId' => '327991330620101',
'secret' => '79asecretcc4300',
'cookie' => true
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$params = array(
'scope' => 'publish_stream',
'redirect_uri' => 'https://apps.facebook.com/quiet_quies/'
);
$loginUrl = $facebook->getLoginUrl($params);
header('Location: ' . $loginUrl);
}
Does anybody have an idea about this ? It's really driving me mad...
Thanks for you help.
yes, #CBroe is right, in your php code try replacing header('Location: ' . $loginUrl); line with
echo "<script language=javascript>top.location.href ='".$loginUrl."'</script>";
it should work then.

Facebook application - server not responding

After the FBML problems I switched to iFrame apps. All well for now except that 2 things:
1) if I did not entered in the app for a few hours and I try to enter, sometimes it gives me the error page that my server did not responded. It shows the Faceboob page with iFrame inside showing the error. After 1 or 2 refreshes it's working fine.
2) I implemented the new SDK with login like this
$facebook = new Facebook(array(
'appId' => $fbID,
'secret' => $fbSecret,
'cookie' => true,
));
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
d($e);
$user = null;
}
}
if (!$user) {
echo "<script type='text/javascript'>
top.location.href = '$loginUrl';
</script>";
exit;
}
The problem is my first redirect, when user enters for the first time. It redirects to my server URL not my Facebook app URL. If I try to put it like this:
$loginUrl = $facebook->getLoginUrl(
array(
'redirect_uri' => 'http://apps.facebook.com/xxx/'
)
);
the login is entering in an infinite loop.
Any help solving this two problems is welcome:-)
Thanks
Darko4spain when the user is redirected back to your site, you can detect if is in iframe with javascript and send them back. I have same issue with my app. This is not a pretty fix but it works.
if (window!=window.top) {
//FB.Canvas.setAutoResize();
setTimeout("FB.Canvas.setAutoGrow()", 1400);
}else {
top.location.href = 'https://apps.facebook.com/AnotherFeed/?ref=redirect#comments';
}
example: https://anotherfeed.com/plugins/index.php will redirect you back to my canvas if you are not in the canvas.

How to login with OFFLINE_ACCESS using the new Facebook PHP SDK 3.0.0?

with the old (2.x) SDK I used this to log someone with offline_access:
$session = array
(
'uid' => $userdata['fb_uid'],
'sig' => $userdata['fb_sig'],
'access_token' => $userdata['fb_access_token']
);
$facebook->setSession($session);
In the new SDK this function doesnt exist anymore. I think I need to login using:
setPersistentData($key, $value)
but this function is protected and I dont know what 'code' is? Do I need this to log the user in or not? And what's going on with 'sig'? Don't I need this anymore?
Hope someone already figured this out because the documentation really doesn't help!
With the Facebook PHP SDK v3 (see on github), it is pretty simple. To log someone with the offline_access permission, you ask it when your generate the login URL. Here is how you do that.
Get the offline access token
First you check if the user is logged in or not :
require "facebook.php";
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
// The access token we have is not valid
$user = null;
}
}
If he is not, you generate the "Login with Facebook" URL asking for the offline_access permission :
if (!$user) {
$args['scope'] = 'offline_access';
$loginUrl = $facebook->getLoginUrl($args);
}
And then display the link in your template :
<?php if (!$user): ?>
Login with Facebook
<?php endif ?>
Then you can retrieve the offline access token and store it. To get it, call :
$facebook->getAccessToken()
Use the offline access token
To use the offline access token when the user is not logged in :
require "facebook.php";
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$facebook->setAccessToken("...");
And now you can make API calls for this user :
$user_profile = $facebook->api('/me');
Hope that helps !
With PHP SDK 2.0 (I guess), I just use it like
$data = $facebook->api( '/me', 'GET', array( 'access_token' => $userdata['fb_access_token'] ) );
This should work with the newer one to as it seems to be more of a clean approach than rather setting up sessions by ourself. Can you try?
Quentin's answer is pretty nice but incomplete, I think. It works nice, but I for example getUser() isn't working in that time because userId (which is getUser() returning) is cached.
I have created a new method to clear all caches and save it persistently.
public function setPersistentAccessToken($access_token) {
$this->setAccessToken($access_token);
$this->user = $this->getUserFromAccessToken();
$this->setPersistentData('user_id', $this->user);
$this->setPersistentData('access_token', $access_token);
return $this;
}