简体   繁体   English

如何使用Open Graph将文章发布到时间轴?

[英]How to publish an article using Open Graph to timeline?

I've been working tirelessly for the last eight or so hours trying to format my Wordpress blog in a way that means that a user can click a button and publish the article to a ticker, by using the Open Graph settings for Article. 在过去八小时左右的时间里,我一直在不懈地努力,尝试以某种方式来格式化Wordpress博客,这意味着用户可以使用“文章”的“打开图表”设置,单击一个按钮并将该文章发布到置顶栏中。

I have been using the tutorial found here . 我一直在使用这里找到的教程。

Unfortunately, I have not been able to complete it as every time I click the "Publish" button I have created, I get an error message pops up. 不幸的是,由于每次单击创建的“发布”按钮时,我都无法完成该操作,并弹出错误消息。

When using Facebook's debugger I see no problems and all the necessary tags are in place (I have a plugin that does it for me, which is perfect). 使用Facebook的调试器时,我看不到任何问题,并且所有必需的标签都已放置到位(我有一个插件可以帮我完成,非常完美)。

Here are the alterations I have made to my header.php file to fit in with the tutorial: 这是我对header.php文件所做的更改,以适合本教程:

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

Added the following before </head> : </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>

Placed a login button clearly that asks permission: 清晰地放置了一个登录按钮,要求许可:

    <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>

And finally placed the following at the point on the page where I want the button to appear: 最后将以下内容放置在页面上我希望按钮出现的位置:

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

On my Open Graph settings, I have the action type 'Read' as well as the object type 'Article'. 在“打开图”设置上,我的操作类型为“读取”,而对象类型为“文章”。

How come this isn't working for me? 为什么这对我不起作用?

Its works for me, trough that tutorial . 通过该教程对我有用

Did you add opengraph tags in your Head Section, like.. 您是否在标题部分添加了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>

New things about og:article og的新事物:文章

您的操作类型必须为发布

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

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