I keep getting this error when I try to use my app I created for Facebook. When I go the the url for the app it take me to the login page, but when I log in I get a pop up box with the error.
App Not Setup: The developers of this app have not set up this app
properly for Facebook Login.
Every time I click ok it just reloads the popup again.
I have already changes the satatus to Live under status and review in my dashboard.
When I log into my account on facebook, it works fine, but I suppose this is because I am set as an admin for the app on the dashboard.
But other users get the problem above.
The code used:
require_once('facebook-php-sdk/src/facebook.php');
$facebook= new Facebook(array(
'appId' => $this->config->item('app_id'),
'secret' => $this->config->item('app_secret'),
'allowSignedRequest' => true,
));
$_REQUEST += $_GET;
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me?fields=picture.width(100).height(100),first_name,last_name,username,email');
} catch (FacebookApiException $e) {
$user = null;
}
} else {
$login_url = $facebook->getLoginUrl(array(
'scope' => 'email'
));
redirect($login_url, 'refresh');
}
This code is in my controller of my codeigniter application which I built the app.
How do I fix this?
UPDATE:
After I added the app as a canvas app this error seemed to go away, however there is still a problem.
I added the Facebook app platform and entered the canvas url, secure canvas url etc.
When I go to the app at the canvas page https://apps.facebook.com/MyApp/ - it work fine as I am a app administrator I guess.
However when an external user goes to the canvas page it just remain blank, but if a user goes to the canvas url http://apps.mydomain.com/MyAPP the app asks for their permissions and works fine as a website.
It just remains blank to users on the canvas page. Why doesn't the canvas page ask for permission?
Help Please.
EDIT:
require_once('facebook-php-sdk/src/facebook.php');
$facebook= new Facebook(array(
'appId' => $this->config->item('app_id'),
'secret' => $this->config->item('app_secret'),
'allowSignedRequest' => true,
));
$_REQUEST += $_GET;
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me?fields=picture.width(100).height(100),first_name,last_name,username,email');
} catch (FacebookApiException $e) {
$user = null;
}
} else {
$login_url = $facebook->getLoginUrl(array(
'scope' => 'email'
));
require_once('facebook-php-sdk/src/facebook.php');
$facebook= new Facebook(array(
'appId' => $this->config->item('app_id'),
'secret' => $this->config->item('app_secret'),
'allowSignedRequest' => true,
));
$_REQUEST += $_GET;
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me?fields=picture.width(100).height(100),first_name,last_name,username,email');
} catch (FacebookApiException $e) {
$user = null;
}
} else {
$login_url = $facebook->getLoginUrl(array(
'scope' => 'email'
));
echo("<script> top.location.href='" . $login_url . "'</script>");
}
Why doesn't the canvas page ask for permission?
Because you are redirecting inside of the iframe, but the FB login dialog does not want to be displayed in (i(frames) – for the obvious reason, that that would lead to a lot of phishing, since users are supposed to see that the page they are entering their login credentials too is actually the real FB site.
So you have to redirect within the top window instance, via JavaScript:
top.location.href = '…';
Related
Everything works fine with test users but when I publish my app and user clicks on app the permission popup dialog box does not appear. I guess there is some oauth problem but not sure. Please help me out
require 'facebook-files/facebook.php';
$app_id='xxxxxxxxxx';
$secret='xxxxxxxxxxxxx';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $secret,
'cookie'=> true,
'grant_type' => 'client_credentials'
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
//$access_token = $facebook->getAccessToken();
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
$friends = $facebook->api('/me/friends?fields=id,name,birthday,picture');
$event = $facebook->api('/me/?fields=events.fields(id,name)');
} catch (FacebookApiException $e) {
echo "Exception".error_log($e);
$user = null;
exit;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'read_stream,publish_actions,publish_stream,user_birthday,friends_birthday', 'display'=>'popup')
);
}
Make sure to add your site to the "valid oauth redirect uris" input field in your app's settings.
This code is used to get facebook data from users of my codeigniter application that I would be launching in a facebook page tab.
require_once('facebook-php-sdk/src/facebook.php');
$facebook= new Facebook(array(
'appId' => $this->config->item('app_id'),
'secret' => $this->config->item('app_secret'),
'allowSignedRequest' => false,
));
$_REQUEST += $_GET;
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me?fields=picture.width(100).height(100),first_name,last_name,username,email');
} catch (FacebookApiException $e) {
$user = null;
}
} else {
$login_url = $facebook->getLoginUrl(array(
'scope' => 'email'
));
redirect($login_url, 'refresh');
}
I want it so that if the user is already logged into facebook that when they open the tab to use the app, instead of being asked to log in, that the dialog box come up asking for permissions. I need email permissions.
How do i skip the login to get permissions step if a user is already logged into Facebook, and just have the dialog box appear asking for permissions?
I have tried to create a facebook login, but it seems after it redirects it to the my controller, I don't know how to fetch the data. I know I need to call the https://www.facebook.com/dialog/oauth? part, but I don't know how.
What I did in my view:
require_once(__DIR__."/facebook/facebook.php");
$facebook = new Facebook(array( 'appId' => 'MY_APP_ID', 'secret' => 'MY_APP_SECRET',));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
$params = array( 'scope' => 'email', 'redirect_uri' => 'http://mywebsite.com/some/directory/loginusingFacebook', );
$loginUrl = $facebook->getLoginUrl($params);
Login with facebook
I don't know how to call https://www.facebook.com/dialog/oauth? so what I did is after I get in the loginusingFacebook function I try redirecting the url to this:
My Controller after I click the login button:
redirect(https://www.facebook.com/dialog/oauth?client_id="MY_APP_ID"&redirect_uri="http://mywebsite.com/some/directory/anotherfunction"&scope="user_birthday,email");
But I'm having errors with it. How do I pass the user data to loginusingFacebook the first time around with out having to redirect it to the oauth facebook page?
I was hoping that I could get it to go to loginusingFacebook or anotherfunction function with the authentication data and userdata so I could echo it out and save it in my database.
I just needed to remove the quotation mark on the redirect_uri.
I want to post a message on facebook wall from our site. First I am getting error as
Uncaught OAuthException: (#200), when trying to post on wall
Now I am not getting the error but the code is not working.
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'cookie' => true,
'req_perms' => 'email,read_stream,read_friendlists,publish_stream,offline_access,manage_pages',
));
$user = $facebook->getUser();
$token = $facebook->getAccessToken();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if (!empty($user_profile )) {
$username = $user_profile['name'];
$uid = $user_profile['id'];
try {
$post=$facebook->api("/".$uid."/feed", "post", array(
'access_token' => $token,
'message' => 'test',
));
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
But no message is coming what to do? Is there any problem while creating the application?
Here's my wild guess, since our Comment Q&A wasn't going to work very well.
If you authorize your app with some set of permissions, and subsequently change the permissions that your app requests (at the app admin page), your existing authorization does not update to include the new permissions. Your app will still function, but the actions that require the new permissions will fail.
You can test if this is causing your error by simply removing the app from your personal account app settings page, and re-approving the app with the new permissions. If your problem vanishes, then congratulations. If not, you'll need to do more detective work. Your code appears to be fine.
Now I'm developing a mobile web application using facebook connect, but I am having problems with the OAuth Dialog. I use the following facebook documents for my reference:
http://developers.facebook.com/docs/guides/mobile/#web
I choose to use the OAuth Dialog instead of the Login Button because mobile browsers do not recognize the FBML (I use the Blackberry browser on testing). The OAuth Dialog also lets me add a list of permissions within the parameters of scope. But the problem is when I've logged in using the OAuth Dialog, the parameter $me wasn't recognized so that the login button still appears and doesn't not change to the logout button.
Here is an example of my code:
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'cookie' => true,
));
$session = $facebook->getSession();
$me = null;
// Session based API call.
if ($session) {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$accessToken = $facebook->getAccessToken();
} catch (FacebookApiException $e) {
error_log($e);
}
}
if ($me) {
echo "<img src=\"images/logoutFB.gif\">";
} else {
echo "<img src=\"images/loginFB.gif\">";
}
Is the parameter $me can't be used if I use the OAuth Dialog to connects to facebook?
So how do I know that I am already logged into facebook or not if I use the OAuth Dialog?
Please help if you guys have the solution.
Looks like you need to use the updated PHP-SDK
getSession() has been replaced by getUser():
require './src/facebook.php';
$facebook = new Facebook(array(
'appId' => '135669679827333',
'secret' => 'xxxxxxxxxxxxxxxx',
));
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
$user = null;
}
}