gpt4 book ai didi

javascript - 使用 js sdk 触发 facebook 操作 "like"

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:37:14 26 4
gpt4 key购买 nike

通过 FB 的 js sdk 触发“赞” Action 的正确语法是什么?自定义操作如下所示:

FB.api('/me/recipebox:cook', 'post', 
{ recipe : 'http://www.example.com/pumpkinpie.html' });

根据:https://developers.facebook.com/docs/opengraph/actions/#create


编辑 - 这是我最终使用的:

                $("#testLink").click(function(){
$.post("https://graph.facebook.com/<?php echo $user_profile[id]; ?>/og.likes",
{
access_token: FB.getAuthResponse()['accessToken'],
object: "http://www.matrym.com/fb/temp.php"
},
function(data) {
alert("Data Loaded: " + data);
}
);
});

最佳答案

一旦你满足以下条件...

An app can publish a built-in Like action, on behalf of the user, as long as the following conditions are true:

  • The viewer of the in-app content is a Facebook user who has Facebook-authed and granted the app publish_actions permission
  • The in-app content has an Open Graph object page that is properly marked-up using Open Graph metatags
  • The viewer has intentionally clicked on an in-app “like button” associated with the in-app content

您可以像这样调用 API:

FB.api('/{object id}/likes', 'post');

引用:https://developers.facebook.com/docs/opengraph/actions/builtin/likes/

“喜欢”必须由网站管理员预先配置,否则 Facebook 不知道您实际上“喜欢”什么。每个赞都有一个与之关联的对象 ID。如果是你自己的网站,你必须设置你网站上的东西可以被点赞(并且FB关联一个ID),然后你可以代表用户为那个对象提交点赞。

关于javascript - 使用 js sdk 触发 facebook 操作 "like",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11218218/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com