1
votes

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",
    ));
2

2 Answers

6
votes

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.

-1
votes

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",
));