简体   繁体   English

Facebook赞按钮和打开图

[英]Facebook Like button and open graph

I previously asked about making a custom like message on a users page and was directed to use open graph. 之前,我曾问过要在用户页面上制作类似自定义消息的内容,并被指示使用开放图。 I have tried the tutorial and can't seem to get it to work with my like button, can anyone help or offer some advice? 我已经尝试过该教程,但似乎无法使其与“喜欢”按钮一起使用,有人可以提供帮助或提供建议吗?

i have used the debug tool and get no errors and am a little confused as to what i should do next. 我已经使用了调试工具,但没有收到任何错误,对于接下来应该做什么我感到有些困惑。 My app uses a fixed php header and the body content is changed dynamically using AJAX. 我的应用程序使用固定的php标头,并且使用AJAX动态更改主体内容。 what i am trying to do is get a user to 'like' a coupon and it shows up on their site with my custom message, something like "someone has used coupon A from www.somesite.com" 我要做的就是让用户“喜欢”优惠券,并且该优惠券会在我的自定义消息中显示在他们的网站上,例如“有人使用了www.somesite.com的优惠券A”

Below is what is in my head; 下面是我的头脑;

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# <?php echo APP_NAME;?> fb: http://ogp.me/ns/fb/<?php echo APP_NAME;?># test: http://ogp.me/ns/fb/test#">
  <meta property="fb:app_id"      content="xxxxxxxxxxxxxxx" /> 
  <meta property="og:type"        content="<?php echo APP_NAME;?>:coupon" /> 
  <meta property="og:url"         content="http://somesite.com/" /> 
  <meta property="og:title"       content="Sample Coupon" /> 
  <meta property="og:description" content="Some Arbitrary String" /> 
  <meta property="og:image"       content="http://ogp.me/logo.png" />

and here is my like script, which currently works, but for the page and not the coupon. 这是我喜欢的脚本,该脚本当前有效,但适用于页面而非优惠券。

<!-- Code for FB like button -->
<div id="fb-root"></div>
<script>
    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=xxxxxxxxxxxxxxx";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

<div class="fb-like" data-href="http://apps.facebook.com/test/" data-send="false" data-width="450" data-show-faces="false"></div>

Using the open graph tags only enable you to post stories like this: User XYZ likes ABC on website.com 使用打开的图形标记仅使您能够发布这样的故事:用户XYZ喜欢website.com上的ABC。

If you would like to specify your own actions (eg use) and objects ('coupon') you also need to create an application that will allow you to do this. 如果您想指定自己的操作(例如使用)和对象(“优惠券”),则还需要创建一个应用程序来执行此操作。

You can find a step by step tutorial on how to do this here: https://developers.facebook.com/docs/opengraph/tutorial/ 您可以在此处找到有关如何执行此操作的分步教程: https : //developers.facebook.com/docs/opengraph/tutorial/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM