XFBML 版本的 Facebook Like 按钮是否需要 appId?
我真的很困惑。
我正在尝试在我的网站上使用一些非常简单的 Facebook 插件,特别是基本的“喜欢”按钮。
我已经知道如何将限制版本与 iFrame 一起使用。
然而,现在我正在尝试找出 XFBML 方法,而在线文档似乎对您已经知道的内容做出了很多假设,并且非常缺乏工作示例。例如,他们向您展示了如何调用 JavaScript Init 并为您提供了元素 fb:like 的单行 HTML 代码...但我看不到任何有关如何显示/隐藏面孔、设置默认字体等的示例就像 iFrame 代码中一样。
我后来发现您需要将它们作为属性添加到元素中,但这要归功于 StackOverlfow,而不是 Facebook 文档,它只会让您原地踏步。
<fb:like href="http://mydomain.com" show_faces="true" action="recommend" colorscheme="light" width="400" height="35" />
好的,现在使用 XFBML 代码时,它的高度应该根据我是否登录而自动扩展/收缩。
我不知道我是否应该最初将高度设置为“80”,或者是否会自动发生。
我不知道在 Init 脚本中应该使用什么作为“你的应用程序 ID”。没有应用程序...只是一个 Facebook 公司页面...那么当我只是在网站上放置“赞”按钮时为什么需要应用程序 ID?
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'your app id',
status: true,
cookie: true,
xfbml: true
});
};
对这些问题的任何启发将不胜感激。
谢谢你!
I'm really confused.
I'm trying to use some of the very simple Facebook plugins on my site, specifically the basic "Like" button.
I already know how to use the limited version with an iFrame.
However, now I'm trying to figure out the XFBML method and the online documentation seems to make a lot of assumptions about what you already know and really short on working examples. For example, they show you how to call the JavaScript Init and give you the single line of HTML code for element fb:like... but I could not see any examples of how to show/hide faces, set the default font, etc. like in the iFrame code.
I've since figured out that you need to add them as attributes to the element but that was thanks to StackOverlfow and no thanks to the Facebook documentation which simply takes you in circles.
<fb:like href="http://mydomain.com" show_faces="true" action="recommend" colorscheme="light" width="400" height="35" />
Ok, so now when using the XFBML code, it's height should expand/contract automatically depending on being logged in or not I assume.
I do not know if I'm supposed to initially set the height to "80" or if that happens automatically.
And I have no idea what I'm supposed to use for 'your app id' in the Init script. There is no App... just a Facebook Company Page... so why would I need an App Id when I'm just putting a Like button on a website?
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'your app id',
status: true,
cookie: true,
xfbml: true
});
};
Any enlightenment on these issues would be appreciated.
Thank-you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在拔掉我所有的头发后回答我自己的问题......
http://developers.facebook。 com/docs/guides/web/
“JavaScript SDK 要求您向 Facebook 注册您的网站以获取应用程序 ID(或 appId)。appId 是唯一标识符为您的网站提供适当的安全级别,以确保我们在用户和您的网站之间建立适当的安全级别。以下示例展示了如何在您获得 appId 后加载 JavaScript SDK:”
http://developers.facebook.com/setup/
该页面/表单的标题是创建应用程序。我仍然不明白为什么他们不使用更通用的术语。我不是在“创建应用程序”,也不认为我的网站是应用程序。
Answering my own question, after pulling out all my hair...
http://developers.facebook.com/docs/guides/web/
"The JavaScript SDK requires that you register your website with Facebook to get an App ID (or appId). The appId is a unique identifier for your site that ensures that we have the right level of security in place between the user and your website. The following example shows how to load the JavaScript SDK once you have your appId:"
http://developers.facebook.com/setup/
The title of that page/form is Create an App. I still don't understand why they don't use more generic terminology. I'm not "creating an app" and I don't consider my website to be an app.
我没有 appId,但刚刚从 类似代码生成器 它似乎在我的本地环境中工作(使用 localhost:8000 但仍然有 136 个赞)。当我按下按钮时,我会按预期弹出 Facebook 登录窗口。
I don't have an appId but just got this code from the like code generator and it seems to work in my local environment (which uses localhost:8000 yet still has 136 likes). When I press the buttons I get the facebook login popup as expected.
你可以做...
上面的工作,但喜欢你自己,并注意Facebook如何将真实的喜欢与Facebook注册的网站(提供一个垃圾页面,#followers,#talking等),从它不知道的喜欢的网址分开。 (至少该网站的计数器确实在增加)。这有点违背了被喜欢的目的。我可能是错的,但我认为它甚至没有发布有关后者的消息。
这太糟糕了,因为我的 Facebook 电话号码已经用完了:)
然后,至少对我来说,还有一个更大的问题。如果你要奖励某人喜欢你,你不能确定他们真的这么做了,因为这是 js。如果您尝试使用 js 重定向到奖励页面,用户只需剪切粘贴该 url 即可。您可以设置一个 rnd 会话变量,将其传递给 js,然后使用它将 js 重定向到 php 页面,但用户也可以弄清楚这一点。
你似乎不能(或注释掉 appId)...
所以似乎没有直接的 php 方式。我正在尝试将 iframed Like 按钮 url 传递给 php,用 simple_html_dom.php 解析它,并找到两个主要 div 中哪一个具有“hidden_elem”类。但最终,这是不值得的,因为 Facebook 会把你当作二等公民。
you can do...
the above works, but Like yourself, and and note how Facebook divides up real Likes with Facebook registered sites (giving a spash page, #followers, #talking, etc), from Liked urls it does not know. (the site does, at least, get a increasing counter). It kinda defeats the purpose of being Liked at all. I might be wrong, but I think it does not even post messages about the latter.
this is too bad, because I am running out of phone numbers for Facebook :)
Then, for me at least, there is a bigger problem. If you are going to reward someone for Liking you, you can't really be sure they did, because this is js. If you try to js redirect to a reward page, a user can just cut paste that url. You could set a rnd session var, pass it to js, and redirect js to a php page with it, but a user could figure that out too.
You cant seem to (or commented out appId) ...
so there seems no direct php way. I was playing with passing the iframed Like button url to php, parsing it with simple_html_dom.php, and finding which of the two main divs has the class 'hidden_elem'. But in the end, it just isn't worth it because Facebook will treat you like a second class citizen.