无法像本地主机上的按钮一样测试Facebook(不像以前) [英] Unable to test facebook like button on localhost (unlike before)

查看:142
本文介绍了无法像本地主机上的按钮一样测试Facebook(不像以前)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个带有Facebook社交插件的小网页(如推荐和发送按钮)。我可以在一个多月前在localhost上成功测试按钮和点击事件;但突然之间的按钮现在不在本地主机上工作。只有通过localtunnel在公共IP上部署网页,他们才工作。在本地主机上,他们显示喜欢和名字的数量,但不要在点击按钮时弹出窗口。此外,订阅的事件edge.create不会被触发。

I had developed one small webpage with facebook social plugins (like, recommend and send buttons). I could test the buttons and the click events successfully on localhost till around a month ago; but suddenly the buttons are not working on localhost now. They work only if I deploy the webpage on a public IP through "localtunnel". On localhost, they show the number of likes and names, but don't give a flyout on clicking the button. Also, the subscribed event "edge.create" is not fired.

我已经从Facebook中复制了所有必需的JavaScript,如按钮小部件页面。
我还发现本地主机和隧道部署的流量模式有一些差异。 GET oauth请求在localhost上返回302状态,而在公共域中返回200。此外,在域上部署后,点击按钮以获取一些CSS和图像后,会发出许多GET请求。而本地主机页只提供一个请求并停在那里。
我不明白为什么会发生这种情况。

I have copied all the required javascript from the facebook like button widget page. I also found out that there is some difference in the traffic pattern on localhost and tunneled deployment. The GET oauth request returns 302 status on localhost while 200 on public domain. Also, the deployment on public domain makes many GET requests after clicking the button to fetch some CSS and images. Whereas the localhost page makes only one request and stops there. I am not able to understand why this is happening.

Facebook最近停止支持测试localhost上的按钮所需的任何东西?

Has facebook recently stopped supporting anything required for testing the buttons on localhost?

推荐答案

补充@ C-Dan的答案,确保具有 data-href 属性点到一个活的网站,而不是你的本地主机。这对我来说是个伎俩。

Complementing on @C-Dan's answer, make sure to have the data-href attribute point to a live site, and not your localhost. That did the trick for me.

这篇关于无法像本地主机上的按钮一样测试Facebook(不像以前)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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