Facebook Connect Mobile Web - page requested not found - php

Im creating a mobile website and trying to implement facebook connect. I am using the PHP SDK
I have following code:
$loginUrl = $facebook->getLoginUrl(array(
'auth_token' => $session['auth_token'],
'next' => 'http://www.site.com/fbconnect',
'cancel' => 'http://www.site.com/fbconnect',
'canvas' => 0,
'fbconnect' => 1,
'req_perms' => 'publish_stream'));
I sign in, but I never get redirected back to my app. I stay on m.facebook.com w/ a msg
The page you requested was not found.
Is there something im missing?

Your site details under the "website" section of your app need to point to the same directory as you call from, that is the most common issue for failure to callback to your site. Assuming the "next" is the URL you wish the user to return to of course.

Related

facebook oauth dialog returns blank page

I'm trying to use dialog/OAuth to get the code parameter from Facebook in order to get the token
When I try to log in using generated URL, I get a blank page.
I'm using this code to generate the url
sprintf('https://www.facebook.com/v15.0/dialog/oauth?%s', http_build_query(array(
'client_id' => self::FACEBOOK_APP_ID,
'state' => 'op=add-page',
'scope' => 'pages_show_list,pages_manage_metadata,pages_read_engagement',
'auth_type' => 'rerequest',
'redirect_uri' => url(self::FACEBOOK_APP_REDIRECT_URI),
)));
Url Example
https://www.facebook.com/v15.0/dialog/oauth?client_id=369956434515590&state=op%3Dadd-page&scope=pages_show_list&response_type=code&auth_type=rerequest&redirect_uri=https%3A%2F%2Ftest.com%2Fapi%2Ffacebook%2Fauth
how can I make the dialog appear for approval, so I can get the code parameter
I just needed to add the redirect url in Valid OAuth Redirect URIs
1- go to Facebook Login for business
2- settings
3- add the url in Valid OAuth Redirect URIs
I hope it will help someone

Hybridauth - Can not login with Windows Live

I am working on a simple PHP site and trying to integrate social login in it. So I used Hybridauth library. To login via Windows Live account, I created a new app at here. And in redirect URL, I entered full domain name such as http://mydomain.com because Live does not accept query string in its redirect URL
Here is my config.php
array(
"base_url" => "http://" . $_SERVER['HTTP_HOST'] . $this->base . "/hybridauth/",
"providers" => array (
// windows live
"Live" => array (
"enabled" => false,
"keys" => array ( "id" => "xxxxxxxxx", "secret" => "xxxxxxxxx" )
),
),
"debug_mode" => false,
"debug_file" => ""
);
When I click the login link
Login with Windows Live
I am directed to the link
https://login.live.com/err.srf?lc=1066#error=invalid_request&error_description=The%20provided%20value%20for%20the%20input%20parameter%20'redirect_uri'%20is%20not%20valid.%20The%20expected%20value%20is%20'https://login.live.com/oauth20_desktop.srf'%20or%20a%20URL%20which%20matches%20the%20redirect%20URI%20registered%20for%20this%20client%20application.
with error message "We're unable to complete your request Microsoft account is experiencing technical problems. Please try again later."
I tried to change Redirect URL but the result is same. Can someone fix this issue?
Thanks a lot in advance!
Try this:
"enabled" => true,

PHP SDK, login - go to url and post to wall

I made an app that will allow users to upload one photo/video from localhost (exhibition) to their own wall.
now what I am trying to do is to get the FB login page and after a successful login to redirect to a "please wait..." page that will run the upload code in background. otherwise the user has to wait after logging in without knowing whats happening.
i tried the
"next" => "myurl",
but it doesnt work.
i am using php sdk.
do you have any ideas / references?
Edit:
My code for login dialog:
$login_url = $facebook->getLoginUrl( array( 'scope' => 'photo_upload, publish_stream, share_item', 'next' => 'http://www.google.com') );
header ("Location: $login_url");
I want to redirect this to a preloader html page and then upload using the normal upload code found in my upload.php
Try setting the redirect_uri like this:
$facebook->getLoginUrl(array(
'scope' => 'photo_upload, publish_stream, share_item',
'redirect_uri' => 'http://your.preloadpage'
));
here is an example
$login_url = $facebook->getLoginUrl(array(
'scope' => 'photo_upload, publish_stream, share_item',
'fbconnect' => 1,
'canvas' => 0,
'next' => 'http://localhost/demo/facebook/index.php',
'redirect_uri' => 'http://localhost/demo/facebook/index.php',
));
param "next" indicates the url to be redirected after clicking a "finish"
param "redirect_uri" indicates the url to be redirected after the progressing to the next page.
and the hosts of redirect_uri and next are ought to be yours ,set and added in the facebook app settings.

Error when including redirect_uri with getLoginUrl (Facebook PHP SDK)

I want the user to be redirected to a particular webpage after logging in using Facebook. I created a LoginUrl using Facebook PHP SDK and the user clicks on this link to log in. I followed http://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/ when using the $facebook->getLoginUrl()
Problem: If I were to include the redirect_uri parameter, Facebook gives me an error An error occurred. Please try again later. The login url works fine without including the redirect_uri.
Anyone knows how to fix this? Thanks!
Non-working PHP Code
$loginUrl = $facebook->getLoginUrl(array(
"scope" => "email,user_education_history,user_work_history",
"redirect_uri" => "http://mydomain.com/login/facebook"
));
Working PHP Code
$loginUrl = $facebook->getLoginUrl(array(
"scope" => "email,user_education_history,user_work_history",
));
I had this same exact problem. FB changed the parameter from redirect_url to next from v2 to v3, and is poooooorly documented. Try next, should work for you.
It's pretty old topic, but here is the solution I've found working, if someone reads it later... First thing is that you have missed the comma after "redirect_uri" in your "Non-working PHP Code". And if you have "App on Facebook" selected in your application settings (app in Canvas) then your redirect_uri must be the same as the url you have set for Canvas App. If you are using just Page Tab, the redirect_uri can be anything.
$loginUrl = $facebook->getLoginUrl(array(
"scope" => "email,user_education_history,user_work_history",
"redirect_uri" => "http://mydomain.com/login/facebook",
));

Facebook App via PHP SDK - Redirecting back to page where someone added my app after getting permissions

I have little problem. When I need my app to ask user to grant permissions to the app I use following code:
<?php
$loginUrl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'email,publish_stream,offline_access',
));
?>
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
I works OK, but after user press "grant permissions" he is redirected to my app URL. I mean like http://mydomain.com/myapp/ directly, not my app page on Facebook.
I can work around it - I know my app's Facebook address, so I redirect him to proper http://apps.facebook.com/myappname. It works OK too. BUT - when somebody adds my application on some page tab - here is where problem appears. Because I don't know where to redirect user anymore - I don't know, from what page my app was called.
Is there any way to get to know, from what page my app was called, or, even better, to make Facebook properly redirect user to the "facebook page" where app tab were added after "grant permission" dialog ?
You can set redirect_uri like so:
<?php
$loginUrl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'email,publish_stream,offline_access',
'redirect_uri' => 'http://yourdomain.com/app', //the url to go to after a successful login
));
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
?>
Seems to be the only thing you can do is detect if the user is viewing your page from outside of facebook and then redirect them to your facebook app page.

Categories