本文介绍了Facebook喜欢按钮+ Phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Phonegap(HTML + JS)应用程序中使用Facebook Like按钮,但它不工作。

I'm trying to use Facebook Like button in my Phonegap (HTML + JS) app, but it doesn't work.

但是当我用Phonegap BUild构建它并在智能手机上运行时,该按钮不显示。

But when I build it with Phonegap BUild and run it in my smartphone, the button is not showed.

我使用下面的代码:

<div class="fb-like" data-href="https://www.facebook.com/pages/Save-Points/293951217439051" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>


推荐答案

当前实现类似操作的方法是使用打开图形对象 og.like - FB的文档。重要的是要注意,这个方法需要用户的 publish_actions 权限。

The current way to implement the like action is by using the open graph object og.like - FB's documentation here. It's important to note that this method requires the publish_actions permission from the user. It's a bit of work to get this all running smoothly, but it is possible.

已提供指南。以下是我的部分评论的说明:

The phonegap-facebook-plugin has provided a guide here. Below are the instructions with some of my comments:

这意味着没有竖起符号 - / p>

This means no "thumbs up" symbol - quite a frustration!

除了检查用户是否登录之外,重申您必须检查您的应用程序是否具有用户的 publish_actions 权限。

Along with checking a user is logged in, to reiterate you must check your app has publish_actions permission for the user. Though you could possibly request this upon the Like action.

此外,数组位于 data 属性中。响应对象。如果你检查用户是否喜欢这个URL,你基本上想检查 response.data.length> 0

Also, the array is in the data property of the response object. If you're checking as to whether the user has liked this URL, you'll basically want to check response.data.length > 0.

完成后,用户已成功地接受了URL,现在 GET 返回一个对象的数组。

After doing this, the URL has been successfully liked by the user, and now the GET method will return an array with one object. Calling this when the user already has liked the URL will result in an error.

DELETE )方法不同于其他 - 它不基于 / me ,而不是通过URL过滤,你使用like id。您可能必须调用上述 GET 方法来获取ID(do response.data [0] .id )。

The unlike (DELETE) method is different to the rest - it's not based off /me, and instead of filtering via URL, you use the like id. You'll likely have to call the previously described GET method to get the ID (do response.data[0].id).

这篇关于Facebook喜欢按钮+ Phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 22:30