admin管理员组文章数量:1323702
What is the correct syntax for triggering a "like" action via FB's js sdk? A custom action looks like this:
FB.api('/me/recipebox:cook', 'post',
{ recipe : '.html' });
According to:
Edit - This is what I ended up using:
$("#testLink").click(function(){
$.post("/<?php echo $user_profile[id]; ?>/og.likes",
{
access_token: FB.getAuthResponse()['accessToken'],
object: ".php"
},
function(data) {
alert("Data Loaded: " + data);
}
);
});
What is the correct syntax for triggering a "like" action via FB's js sdk? A custom action looks like this:
FB.api('/me/recipebox:cook', 'post',
{ recipe : 'http://www.example./pumpkinpie.html' });
According to: https://developers.facebook./docs/opengraph/actions/#create
Edit - This is what I ended up using:
$("#testLink").click(function(){
$.post("https://graph.facebook./<?php echo $user_profile[id]; ?>/og.likes",
{
access_token: FB.getAuthResponse()['accessToken'],
object: "http://www.matrym./fb/temp.php"
},
function(data) {
alert("Data Loaded: " + data);
}
);
});
Share
Improve this question
edited Jun 27, 2012 at 19:59
Matrym
asked Jun 27, 2012 at 1:31
MatrymMatrym
17.1k35 gold badges99 silver badges141 bronze badges
1
- So what is the URL that was shared? Can you set the image and text that goes with the like? – Drew Baker Commented Sep 1, 2012 at 6:43
1 Answer
Reset to default 5Once you satisfy the following conditions...
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
you call the API like so:
FB.api('/{object id}/likes', 'post');
Reference: https://developers.facebook./docs/opengraph/actions/builtin/likes/
"Likes" have to be pre-configured by webmasters, otherwise Facebook has no idea what you're actually "liking". Each like has an object id associated with it. If it's your own website, you have to set up what on your site can be liked (and FB associates an ID with it), then you can submit a like on the user's behalf for that object.
本文标签: javascriptTrigger facebook action quotlikequot with js sdkStack Overflow
版权声明:本文标题:javascript - Trigger facebook action "like" with js sdk - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742131199a2422167.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论