简体   繁体   English

facebook php sdk设置重定向网址

[英]facebook php sdk setting the redirect url

What I do is, 我做的是,

I start by making a call with ajax to the controller/function "users/authenthicate" 我首先使用ajax调用控制器/函数“users / authenthicate”

This function get's the loginurl from the sdk and returns it to javascript wich does the window.open.href... sofar sogood.. I get directed to the facebook loginpage, 这个函数得到了来自sdk的loginurl并将其返回给javascript,而window.open.href ... sofar sogood ..我被定向到facebook登录页面,

but after a successvol login, it redirects back to the same users/authenticate. 但是在successvol登录后,它会重定向回相同的用户/身份验证。

QUESTION: is this the normal behaviour? 问题:这是正常行为吗? or can I set the redirecturl.. 或者我可以设置redirecturl ..

QUESTION: it returns the url without a slash between the questionmark so the function is never recognized like this "users/authenthicate?bladeblibla". 问题:它返回了在问号之间没有斜线的url,因此函数永远不会被识别为“users / authenthicate?bladeblibla”。

*I did set some url when I registred the application, but that was a completely different url something like "http://www.domain/users/facebook_login"* *当我注册该应用程序时,我确实设置了一些网址,但这是一个完全不同的网址,例如“http://www.domain/users/facebook_login”*

thanks Richard 谢谢Richard

You can set the redirect URI as follows: 您可以按如下方式设置重定向URI:

$linkToOauthDialog = $this->facebook->getLoginUrl(

  array(
     'scope'         =>  SCOPE_OF_THE_APP,
     'redirect_uri'  =>  REDIRECT_URI
  )

);

You should also have in mind that Safari doesn't allow setting third party cookies in an iframe, that's why you need to redirect to your own domain first, where you set a cookie and redirect to facebook again. 您还应该记住Safari不允许在iframe中设置第三方cookie,这就是为什么您需要首先重定向到您自己的域,在那里您设置cookie并再次重定向到Facebook。 Otherwise you end up in an infinite loop. 否则你最终会陷入无限循环。

I have described this method in more detail here: Safari 3rd party cookie iframe trick no longer working? 我在这里更详细地描述了这种方法: Safari第三方cookie iframe技巧不再有效?

Yes, this is the default behaviour of the php sdk. 是的,这是php sdk的默认行为。 When you call getLoginUrl() and you don't specify the redirect_uri at the param array, it will try to use the current url. 当你调用getLoginUrl()并且你没有在param数组中指定redirect_uri时,它将尝试使用当前的url。

I think what you would want to use is the JS sdk's FB.login() method instead of redirects with window.open (will be opening popups trough but you will get information back in you page's js). 我想你想要使用的是JS sdk的FB.login()方法,而不是使用window.open重定向(将打开弹出窗口,但你会在你的页面的js中获得信息)。

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

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