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;
}
Related
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.
I searched all web long for this problem but nothing seems to fix it.
I am simply writing a post to a facebook page, the post is visibile on the page but only by myself and no from other admins or users.
How can it be possible?
I am using this function (also i'm pretty sure that the whole code is working as the post is on the page!):
$postResult = $facebook->api($post_url, 'post', $msg_body );
First i was guessing that was a privacy problem, but the page doesn't have that kind of parameter.
Whole code is:
post_url = '/'.$page_id.'/feed';
$page_info = $facebook->api("/$page_id?fields=access_token");
//die(print_r($page_info));
//posts message on page statues
$msg_body = array(
'access_token' => $page_info['access_token'],
'message' => "test"
);
if ($fbuser) {
try {
$postResult = $facebook->api($post_url, 'post', $msg_body );
} catch (FacebookApiException $e) {
echo $e->getMessage();
}
}
#------------# EDIT #------------#
I still have the same problem, also, i checked a feed "manually" posted and a feed from my script, and the fields are exactly the same... that's insane.
#------------# EDIT II: #------------#
I tried with a curl, nothing seems to work :/
Problem has been solved.
As an idiot, SandBox mode was activated (i didn't know that eveything done by the app was binded by the SandBox).
You need some kind of page access token to do that.
Also, what $post_url, stands for? We can't guess from the code you wrote. Anyhow, you post either with $pageid/feed or with me/feed (and an access token). It should be something like $facebook->api( '/me/feed/', 'post', array('access_token' => $page_access_token, 'message' => 'Test message', 'link' => 'http://somelink.com') );
I have this code:
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxx',
'secret' => 'yyyyyyy',
'baseUrl' => 'http://xxx.yyy.zz/',
'appBaseUrl' => 'http://apps.facebook.com/xxxxxx/',
'fileUpload' => 'true',
));
$user = $facebook->getUser();
$params = array(
scope => 'publish_stream,user_photos',
redirect_uri => 'http://www.facebook.com/xxxxxx?sk=app_123456789'
);
if ($user){
....
}
$loginUrl = $facebook->getLoginUrl($params);
if ($user){
// nothing
}else{
echo "<script type=\"text/javascript\">top.location.href = \"".$loginUrl."\";</script>";
}
My problem is, that it gets into an endless loop... reloads the page over and over.
Can someone help me to fix this?
Thank you very much!
I think the problem is your redirect_uri. Try to define the real path to your url (www.yourdomain.com/app/index.php) instead, since Facebook will send a POST (including a code) to that url and won't pass it with the app data or signed request to your iFrame application.
The problem was that the main logic was not int the index.php. After i put everything back into that, the redirection stopped.
I've read a lot of tutorials/articles/questions here about this, as well as trying to find something useful in the fb documentation.
So far I've made no progress at all myself so any input would be greatly appreciated, I'm simply trying to access a list of my photos but all I get is an empty array.
I know I've added more req_perms than I need probably, I just copied the ones from a "working tutorial" that didnt work for me, and after reading a thread here I also added user_photo_video_tags because that had worked for the thread poster (again, not me).
I've gotten the dialog to allow photos sharing my photos with my app, login works without any problems, the access token I get seem to be correct, after logging in I have visited:
https://graph.facebook.com/me/photos?access_token= and the token, and gotten an empty array, if I wasnt logged in or the access_token wasnt linked to my app there would be some error, but all I get is an empty array.
Thanks in advance for any input.
Thanks to Chaney Blu I was able to validate my permissions:
{
"data": [
{
"installed": 1,
"status_update": 1,
"photo_upload": 1,
"video_upload": 1,
"create_note": 1,
"share_item": 1,
"publish_stream": 1
}
]
}
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once 'library/facebook.php';
$app_id = "xxxxxxxxxxxxxxxx";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$loginLink = $facebook->getLoginUrl(array(
'scope' => 'user_status,publish_stream,user_photos,user_photo_video_tags'
));
$logOutLink = $facebook->getLogoutUrl();
$user = $facebook->getUser();
if ($user) {
try {
// User logged in, get token
$token = $facebook->getAccessToken();
//var_dump($token); dumped successfully
// Get public profile info
$user_profile = $facebook->api('/me');
//var_dump($user_profile); dumped successfully
$photos = $facebook->api('/me/photos?access_token=' . $token);
var_dump($photos); // Empty array, BAH!
} catch (FacebookApiException $e) {
$user = null;
}
}
?>
Click here to login if you aren't autoredirected<br /><br /><br />
Click here to logout
Not sure if this is the problem, but try this. It appears you're using the latest PHP SDK. In your getLoginUrl(); calls, try changing 'req_perms' to 'scope'.
Like this:
$loginLink = $facebook->getLoginUrl(array(
'scope' => 'user_status,publish_stream,user_photos,user_photo_video_tags'
));
You can verify that you've authorized the correct permissions by visiting https://graph.facebook.com/me/permissions/?access_token=XXXX
After testing some other permissions I noticed facebook weren't updating the permissions to my token, even when logging out of the app, logging in again and accepting new permissions nothing changed when I looked at the Graph permissions link I got from Chaney Blu.
I used that link to verify the token from facebooks graph api page http://developers.facebook.com/docs/reference/api/ and noticed that token had access to user_photos but not my token.
Going into my facebook settings and removing the app made facebook update my permissions the next time I signed into the app.
Thanks to Chaney Blu for putting me on the right track. Would vote you up if I had the reputation.
I got the sample code from Facebook to post a message. At first it worked fine. The next day I tried to clean up the code and it stopped working. I brought back the sample code from Facebook, to take out all my changes, and it still did not work.
I put in print statements to follow the code.
$user_id is false, so it displayes a login in. The login in no longer goes to a login in screen. It calls my return url, which then sees $user_id as being false and diplays the login in again.
I did notice when my call back was being called, I had the following values:
v?state=452c9492a3d51962909f5e000bcb0965
and code
code=AQDucDgsdc3lZFVN2MC3Oj2oB0n1LT4FjOrG3MbgwL4uhh--LS-mRdtjU-6oSUZxsR6UhTKuUDVn3hrasJAe5r1I6ksIDJz1nnTo1mjCqEInJKvQ2qK5A-N3_Nt5buGLqsirb8ccg21N4nWVWkk_iRePwX9f68qK1j-2O6E_USpKvRJeNP3bcwLBiTBJpDVu7aA#=
I was wondering maybe when I was trying to clean up the code and kept running it, Facebook flagged my app as spamming? I posted 26 posts to my wall - is that too many? And how would I check if my app has been flagged as a spammy app?
This is the sample code I used
<?
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('facebook.php');
$config = array(
'appId' => 'myappid',
'secret' => 'mysecret',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?
if($user_id) {
print ("tryinmg to do a poast");
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => 'www.example.com',
'message' => 'Posting with the PHP SDK!'
));
echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
print ("face book exception log in");
$login_url = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
echo 'Please login.';
error_log($e->getType());
error_log($e->getMessage());
}
// Give the user a logout link
echo '<br />logout';
} else {
print ("no user login in do login");
// No user, so print a link for the user to login
// To post to a user's wall, we need publish_stream permission
// We'll use the current URL as the redirect_uri, so we don't
// need to specify it here
$login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );
echo 'Please login.';
}
?>
</body>
</html>
Naturally, Facebook has a limit for the number of post per day your app can make to a user wall. And FB have policy for user to report spammy apps as well.
The exact maximum number of posts depends on your application FB ranking. In my experience, 26 posts on a user wall is near the limit for new application.
If that is the case, you should receive the error message from Facebook, which says something like "you have reached limit of posts..."
P/s: It seems you need time to refactoring your question, though. If I have not met this situation before, I won't understand your question.