0

我做了我的研究,發現沒有關於這個問題的博客文章。Facebook的JS SDK的股份數量不增加

基本上我使用feed對話框方法爲我的Zend應用程序創建了一個Facebook共享按鈕。

我在view.phtml HTML

<div id="fb_share">Share</div> 
    <?= $this->share->share_count; ?> 
    <p id='msg'></p> 

我facebook.js,處理事件

$(document).ready(function() { 
$('#fb_share').click(function() { 
     link = window.location.href; 
     data = { 
      method: 'feed', 
      link: link, 
      name: $('.thesis').html(), 
      caption: $('.author').html(), 
      description: $('.body').html() 
     }; 
     postToFeed(data); 
    }); 
}); 

function postToFeed(data) { 

    // calling the API ... 
    var obj = { 
    method: data['method'], 
    link: data['link'], 
    picture: data['picture'], 
    name: data['name'], 
    caption: data['caption'], 
    description: data['description'] 
    }; 

    function callback(response) { 
    document.getElementById('msg').innerHTML = "Post ID: " + response['post_id']; 
    } 

    FB.ui(obj, callback); 
} 

代碼片斷有關Facebook在我的viewAction PHP

  $uri = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getRequestUri(); 

      $fql = "SELECT url, normalized_url, share_count, like_count, comment_count, "; 
      $fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM "; 
      $fql .= "link_stat WHERE url = '$uri'"; 

      $apifql="https://api.facebook.com/method/fql.query?format=json&query=".urlencode($fql); 
      $json=file_get_contents($apifql); 
      $fbshare = json_decode($json); 
      $share = $fbshare[0]; 
      //echo($share->share_count); 
      $this->view->share = $share; 
      $this->view->uri = $uri; 

所以共享工程,但share_count並沒有增加每次我分享頁面。

我錯過了什麼嗎?

+0

當我使用常規方法使用 shiva8 2012-03-05 02:49:12

回答

0

使用

FB.ui({ 
      display: 'popup', 
      method: 'stream.share', 
      href: href 
     } 

它會增加計數。