我做了我的研究,没有发现关于这个问题的博客文章。
基本上,我正在使用提要对话框方法为我的 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);
}
在我的 viewAction php 中与 facebook 相关的代码片段
$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 并没有增加。
我错过了什么吗?