news.reads php sdk在facebook上 - 无法发布

时间:2012-09-25 17:30:52

标签: php facebook

我正试图通过news.reads动作发布一个动作,但是我被卡住了。

发送$ facebook-> api后 - 它就像扔了一个“退出”一样,在此行之后没有回复。

代码:

    <?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="he-IL">
    <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# 
                  article: http://ogp.me/ns/article#">
     <meta property="og:type" content="article" /> 
  <meta property="fb:app_id" content="306597542762982" /> 
  <meta property="og:url"    content="http://v2.raal.co.il/index.php" /> 
  <meta property="og:title"  content="הצצה נדירה: יחידת אגוז, קומנדו היבשה של צהל" /> 
  <meta property="og:description" content="יחידת אגוז התאמנה השבוע באחד המתארים הקשים ביותר, מתאר ה..." /> 

     <meta property="og:site_name"            content="פורטל רעל">

     <meta property="article:published_time"  content="DateTime"> 
     <meta property="article:modified_time"   content="DateTime"> 
     <meta property="article:expiration_time" content="DateTime">
     <meta property="article:author"          content="URL to Author object">
     <meta property="article:section"         content="Section of article">
     <meta property="article:tag"             content="Keyword">
 </head>

    <body>


<?Php
//uses the PHP SDK.  Download from https://github.com/facebook/php-sdk
require 'src/facebook.php';


$facebook = new Facebook(array(
  'appId'  => '306597542762982',
  'secret' => '88XX7f1',
));


$user = $facebook->getUser();
if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

if (!$user) {
  $loginUrl = $facebook->getLoginUrl();
  header("Location: " . $loginUrl);
}
    //echo "<script type='text/javascript'>top.location.href = '$url';</script>";




$params = array (
  'article' => 'http://v2.raal.co.il/',
  'access_token' => $facebook->getAccessToken()
);



$out = $facebook->api( '/me/news.reads','post', $params);
var_dump($out);


   ?>

  </body>
</html>

我得到回复:1 2(打印1;打印2;)

而print_r($ out)返回null。

1 个答案:

答案 0 :(得分:4)

第一:文章拼写错误(artice),你检查了吗?

第二:您尝试发布的网址不是文章,您必须在其中添加og:标记,请查看here

第三:您是否拥有publish_stream权限?

您可以使用Graph API Explorer检查输出吗?