简体   繁体   English

在getLoginUrl中包含redirect_uri时出错(Facebook PHP SDK)

[英]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. 我希望在使用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() 我使用Facebook PHP SDK创建了LoginUrl ,用户单击此链接进行登录。当使用$facebook->getLoginUrl()时,我遵循了http://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/ $facebook->getLoginUrl()

Problem : If I were to include the redirect_uri parameter, Facebook gives me an error An error occurred. Please try again later. 问题 :如果要包含redirect_uri参数,Facebook会给我一个错误An error occurred. Please try again later. An error occurred. Please try again later. The login url works fine without including the redirect_uri . 登录网址可以正常运行,而无需包含redirect_uri

Anyone knows how to fix this? 有人知道如何解决这个问题吗? Thanks! 谢谢!

Non-working PHP Code 非工作的PHP代码

$loginUrl = $facebook->getLoginUrl(array(
        "scope" => "email,user_education_history,user_work_history",
        "redirect_uri" => "http://mydomain.com/login/facebook"
    ));

Working PHP Code 有效的PHP代码

$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. FB改变的参数从redirect_urlnext从V2到V3,并poooooorly记录。 Try next , should work for you. next尝试,应该为您工作。

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". 这是一个很老的话题,但是如果有人稍后阅读,这是我发现可以使用的解决方案……第一件事是,您在“非工作PHP代码”中的“ redirect_uri”之后错过了逗号。 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. 并且,如果您在应用程序设置(Canvas中的应用程序)中选择了“ Facebook上的App”,则redirect_uri必须与您为Canvas App设置的URL相同。 If you are using just Page Tab, the redirect_uri can be anything. 如果仅使用页面选项卡,则redirect_uri可以是任何东西。

$loginUrl = $facebook->getLoginUrl(array(
    "scope" => "email,user_education_history,user_work_history",
    "redirect_uri" => "http://mydomain.com/login/facebook",
));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM