问题标签 [facebook-javascript-sdk]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3369 浏览

facebook - Facebook 点赞 API

我在使用 api 之类的 facebook 时遇到了一些麻烦。我正在使用以下代码创建类似按钮:

然后我正在监听该事件并调用一个 javascript 函数,该 ajax 运行一段 PHP,将类似内容插入本地数据库以跟踪该艺术家的所有喜欢。使用此代码:

问题是它并不总是调用这个likeSong 函数并将like 添加到数据库中。

以前有没有人遇到过类似的问题?或者您知道更好的方法吗?

非常感谢

保重,克雷根

0 投票
1 回答
494 浏览

php - Facebook Connect - 显示个人资料图片的最佳方式

我有一个使用 Facebook 连接设置的网站。我也有个人资料页面,显示用户 Facebook 个人资料图片。如果用户没有通过 Facebook 连接,他们仍然可以选择通过输入头像的 url 来使用头像。

Facebook 图片使用 type=large,所以它们是真正的 Facebook 尺寸(我认为)。现在我遇到的问题是,如果有人使用这么大的图像怎么办?它破坏了页面的用户界面?我无法设置图像的大小(通过 HTML),因为它看起来不适合 Facebook 个人资料图像。

解决这个问题的最佳方法是什么?顺便说一句,我正在使用 php。

谢谢

0 投票
8 回答
39456 浏览

javascript - How can I make the Facebook Like button's width automatically resize?

I'm implementing the Facebook Like Button, but I'm running into some trouble with the width. I'm using the JavaScript SDK implementation, not the direct iframe.

According to the documentation, the default width is 450. That's fine, and I understand that the width can be changed by way of the width attribute on the <fb:like> tag. However, my problem is that I really cannot specify a fixed width. Due to the nature of the button, the width is not constant in all states. For example, if no one has liked the page yet it displays "Be the first of your friends to like this"; if someone has, it displays "XXX people like this. Be the first of your friends"; and still if you have liked it, it displays "You like this" or "You and XXX people like this." In other words, there are many states of the button, none of which share a constant width.

This wouldn't be much of a problem if it weren't for the fact that I want to display the button floated on the right-hand side of a <div>. To be clearer, this is what I'm doing:

This works fine, but the problem is that the iframe now has a constant width of 450 pixels. Since the iframe is left-aligned, when the text is shorter there is extra space to the right. I've tried various applications of text-align: right to no avail. And the problem is further compounded by the fact that this is really just fancy markup for an iframe that is added by the FB SDK, so I'm powerless to change any of its contents with CSS or JavaScript.

I need a solution that will either (a) keep the width of the button area dynamic (i.e., it changes according to the content); or (b) right-align everything in the button area.

Thanks for any help anyone can give me!

0 投票
19 回答
105612 浏览

javascript - Facebook Javascript SDK 问题:“FB 未定义”

以下代码,从此处的 Facebook 文档复制而来,在 Chrome 中不适合我。

在 Javascript 控制台中,我得到:

我在 Firefox 或 Safari 中的 SDK 没有任何问题,只有 Chrome。

0 投票
1 回答
465 浏览

facebook - 使用 Facebook Connect 登录时 Facebook Share 无法正常工作

我有一个 Drupal 6 网站,在那里我使用JavaScript SDK实现了 Facebook Connect,并且几个月来一直运行良好。

该站点使用了旧的 Facebook 共享按钮(指向 sharer.php),但它不适用于新的 Facebook Connect API,因此我将其替换为 fb:share-button。

我的问题是 Facebook 分享按钮不适用于通过 Facebook Connect 登录的用户。Facebook Share 的灯箱显示为空,只有加载栏。如果用户以非 Facebook Connect 用户身份登录该站点,则 Facebook 共享正常工作。

我搜索了类似的问题,并在 Facebook 开发者论坛上发现了一个看起来类似问题的未答复帖子。

该网站也使用 Facebook Like 按钮,但据我所知,这些按钮不允许包含来自喜欢的图像的图像,如共享。该网站的所有者需要 Facebook 共享,并且没有计划将其删除以仅与 Facebook 一起使用。

有什么建议么?

谢谢。

0 投票
4 回答
3318 浏览

php - 如何从评论社交插件中获取评论?

我尝试使用图形 api 向那里询问了很多事情,但没有一个是返回评论。我想获得所有评论,并放入一个单独的页面供搜索引擎扫描和索引。评论非常丰富,我想要他们

0 投票
1 回答
876 浏览

facebook - Facebook 登录无法使用 Facebook C# SDK

使用 Facebook C# SDK 的 facebook 登录工作正常,但现在不行!发生了什么?

我让用户使用 Javascript SDK 登录。然后,当我回到页面时,当我不请求权限时,我找不到会话:

当属性是它应该是的时候,它根本不进入动作方法:

在我将用户发送到操作方法之前,我使用 JavaScript 验证用户是否实际登录并且它总是正确的:

你认为问题是什么?

0 投票
6 回答
32843 浏览

facebook - 使用 FB.ui 发布到页面墙

我正在使用FB.ui发布到 Facebook 用户墙。但是,我不确定要使用哪些参数发布到页面或应用程序墙。有链接吗?

我正在尝试以该页面而不是用户帐户的身份发布到页面墙上。

发布到用户帐户的代码:

0 投票
2 回答
1331 浏览

facebook - 获取like-button presser (facebook) 的 facebook-user-id

我正在使用 Facebook Javascript SDK 和 fbml 类似按钮。使用“edge.create”回调我知道有人喜欢一个网址。是否也可以获得facebook-user-id?无需他们使用 FB Connect 登录我的应用程序/域

我想为内部统计数据加倍存储(因为很难通过 facebook.com/insights 获得非常精细的域统计数据)

问候, 尼克拉斯

0 投票
6 回答
10481 浏览

javascript - 如何关闭使用 FB.ui() 打开的 facebook SDK 对话框?

我成功地显示了一个邀请朋友对话框(代码如下所示)。当用户单击跳过 iframe/对话框时,会显示一个新页面。但是从这一点来看,我找不到关闭 iframe/对话框的方法。FB.ui 不返回任何对象,似乎没有 Javascript SDK 方法,并且使用 DOM 遍历和操作对于任何 FB 代码更改都是脆弱的。

有任何想法吗?

(注意:我在facebook 论坛上发布了同样的问题,但没有任何回应。我会更新两者,如果有答案的话。)

Javascript 代码改编自堆栈溢出答案