可以facebook的javascript / php SDK的“talk”如果第三方Cookie被禁用,对方? facebook-> getUser()返回0 [英] can facebook javascript/php SDK's "talk" to each other if 3rd-party cookies are disabled? facebook->getUser() returns 0

查看:126
本文介绍了可以facebook的javascript / php SDK的“talk”如果第三方Cookie被禁用,对方? facebook-> getUser()返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个网站w / facebook的javascript& php SDK的一起工作...它一般工作很好,但是 - 我发现,对于一个测试机器使用chrome,当我执行FB登录从客户端/ javascript侧面,后端的PHP sdk不会识别它 - facebook :: getUser()函数返回0

I'm building a site w/ the facebook javascript&php SDK's working together... It's generally working well, but-- I found that for one test machine using chrome, when I execute FB login from the client/javascript side, the PHP sdk on the back-end would not recognize it -- the facebook::getUser() function returns 0

经过很多头痛和谷歌没有用,我通过chrome开发工具实现/注意,对于正在工作的机器,我看到cookie称为PHPSESSID以及C_user其中包含我的facebook uid和其他名称/值对;而在非工作机器上,我只看到PHPSESSID。然后我发现/意识到非工作机器上的chrome已禁用第三方cookie。

After a lot of head-scratching and googling to no avail, I realized/noticed via chrome dev tools, that for the machines that were working I see cookies called "PHPSESSID" as well as "C_user" which contains my facebook uid, and other name/value pairs; Whereas on the non-working machine, I only see the "PHPSESSID". I then found/realized that chrome on the non-working machine had 3rd-party cookies disabled.

这是显然的问题..我做了一些更多的谷歌但我不能找到一个明确的答案,是否有一个解决方法或更好的方法。

So that is apparently the problem.. I've done some more googling but I cant find a clear answer to whether there's a workaround or better approach.

如果用户/浏览器禁用第三方Cookie,是不是无法集成js + php sdk?我的PHP后端代码如何确定我正在处理哪个Facebook用户?

Is it simply not possible to integrate js+php sdk's if the user/browser disables 3rd-party cookies? How else might my PHP back-end code determine which facebook user I am dealing with?

推荐答案

使用php-SDK getLoginUrl()在页面上提供登录链接,并让用户使用该链接,而不是对javascript login()函数或使用Facebook社交/登录插件执行客户端调用。它可能会在某些时候遇到缺点,但现在似乎在禁用第三方cookie的机器上工作

I've worked around this by providing a login link on the page using the php-SDK getLoginUrl() and having the users use that instead of doing a client-side call to the javascript login() function or using the facebook social/login plugin. It might run into drawbacks at some point, but for now this seems to work on machine(s) that have 3rd party-cookies disabled

这篇关于可以facebook的javascript / php SDK的“talk”如果第三方Cookie被禁用,对方? facebook-> getUser()返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆