1

在过去八个小时左右的时间里,我一直在不知疲倦地工作,试图以一种方式格式化我的 Wordpress 博客,这意味着用户可以通过使用 Article 的 Open Graph 设置来单击按钮并将文章发布到股票行情。

我一直在使用这里找到的教程。

不幸的是,我无法完成它,因为每次单击我创建的“发布”按钮时,都会弹出一条错误消息。

使用 Facebook 的调试器时,我没有发现任何问题,并且所有必要的标签都已到位(我有一个插件可以为我做这件事,非常完美)。

以下是我对header.php文件所做的更改以适应本教程:

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
      xmlns:fb="https://www.facebook.com/2008/fbml">

之前添加了以下内容</head>

<script type="text/javascript">
  function postArticle()
  {
      FB.api(
        '/me/[NAMESPACE]:read?Article=<?php get_permalink() ?>',
        'post',
        function(response) {
           if (!response || response.error) {
              alert('Error occured');
           } else {
              alert('Successful! Action ID: ' + response.id);
           }
        });
  }
  </script>

清楚地放置了一个请求权限的登录按钮:

    <div id="fb-root"></div>
     <script>
     window.fbAsyncInit = function() {
      FB.init({
        appId      : '[APPLICATION ID]', // App ID
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
      });
     };

     // Load the SDK Asynchronously
     (function(d){
      var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
      js = d.createElement('script'); js.id = id; js.async = true;
      js.src = "//connect.facebook.net/en_US/all.js";
      d.getElementsByTagName('head')[0].appendChild(js);
     }(document));
     </script>

     <fb:login-button perms="email,publish_actions,user_actions.news">
    Login with Facebook
    </fb:login-button>

最后将以下内容放在页面上我希望按钮出现的位置:

<fb:add-to-timeline></fb:add-to-timeline>
 <form>
 <input type="button" value="Publish" onclick="postArticle()" />
 </form>

在我的 Open Graph 设置中,我有操作类型“读取”以及对象类型“文章”。

为什么这对我不起作用?

4

2 回答 2

1

它对我有用,通过那个教程

您是否在 Head Section 中添加了 opengraph 标签,例如..

<head prefix="og: http://ogp.me/ns# [YOUR_APP_NAMESPACE]: 
                  http://ogp.me/ns/apps/[YOUR_APP_NAMESPACE]#">
  <title>OG Tutorial App</title>
  <meta property="fb:app_id" content="[YOUR_APP_ID]" /> 
  <meta property="og:type" content="[YOUR_APP_NAMESPACE]:recipe" /> 
  <meta property="og:title" content="[YOUR_TITLEIts]" /> 
  <meta property="og:image" content="http://fbwerks.com:8000/zhen/cookie.jpg" /> 
  <meta property="og:description" content="The Turducken of Cookies" /> 
  <meta property="og:url" content="http://fbwerks.com:8000/zhen/cookie.html">
</head>

关于 og 的新事物:文章

于 2012-03-01T05:02:46.723 回答
0

您的操作类型必须是发布

于 2012-10-26T20:45:25.483 回答