OG meta标签和Facebook'发送'按钮失败

时间:2012-04-18 04:59:41

标签: facebook facebook-graph-api

我很确定元标记和发送按钮代码都很好。我会在下面显示代码,但我很确定代码是正确的。

以下是我认为我的问题源于:

1)我的网站页面上有一个FB“发送”按钮,名为 landing_page.php

2)因此我指定

     <meta property="og:url" content="http://www.oursite.com/landing_page.php"/>

表示页面的“url”元标记。

3)当我转到https://developers.facebook.com/tools/debug - 然后输入    我的网页网址http://www.oursite.com/landing_page.php ---我收到错误消息:

错误解析URL:解析输入网址时出错,未抓取任何数据。

所以我的问题是 - 我必须只在index.php页面上发送发送按钮吗?

只要我放置元标记,我想我可以在任何页面上放置“发送”按钮 并在该页面上发送按钮代码。但Facebook调试器抱怨

错误解析URL:解析输入网址时出错,未抓取任何数据。

如果我将“发送”按钮和相关代码放在“anypage.php”上并尝试使用它 - 出现的发送框选择了我的OG元标记(见下文)和 Facebook调试器无法“刮掉”我网站中的任意页面。

我必须只在index.php页面上发送“发送”按钮吗? 或者我需要更改什么,以便landing_page.php上的发送按钮工作并显示我的OG元标记设置?

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:og="http://ogp.me/ns#"
   xmlns:fb="https://www.facebook.com/2008/fbml">

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 <head>
 <meta property="og:url" content="http://www.oursite.com/landing_page.php"/>
 <meta property="og:title" content="Wow cool title!"/>
 <meta property="og:image" content="http://www.oursite.com/images/logo.png"/>
 <meta property="og:description" content="Hey -- SUPER-COOL!!"/>
  etc.


  </head>
  <body>
  <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_US/all.js#xfbml=1";
            fjs.parentNode.insertBefore(js, fjs); 
        }
        (document, 'script', 'facebook-jssdk'));
       </script>

      <div class="fb-send" data-href="http://www.oursite.com"></div>

2 个答案:

答案 0 :(得分:0)

您还需要添加appid以废弃页面

<meta property="fb:app_id" content="${fb_app_id}"/>

假设您已在landing_page.php中添加了此标记

您可以在网站的任何位置使用此发送按钮

答案 1 :(得分:0)

您需要将元标记放在http://www.oursite.com/landing_page.php中,因为fb未在上述网址上找到任何元标记

同时检查调试工具中的“获取的URL”。这将显示他们从您的网址中找到的确切内容