我有一个插件,我们在社交网络上拉取数量的分享。然而,我们现在正在使用规范的URLS从彭博社拉来文章,它也在统计他们在facebook上的点赞和分享。
我们使用这些数字来支持“热门趋势”小部件。显然,他们的网站很大。因此,这意味着来自彭博社的文章将取代我们的热门帖子小工具。
有没有办法不计算彭博社文章中facebook的分享和点赞数量,而只计算我们网站原生的分享和点赞数量?或者,正如我怀疑的那样,它不应该只吸引基于我们自己的API的股票吗?有点迷惑。
这是我们当前的Facebook计数收集代码。
function getFacebook() {
$query = "SELECT total_count FROM link_stat WHERE url = '$this->url'";
$url = "https://api.facebook.com/method/fql.query?format=json&query=".rawurlencode($query);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$response = curl_exec($ch);
curl_close ($ch);
$response = json_decode($response, 1);
if ( empty( $this->stats['facebook'] ) ) {
$this->stats['facebook'] = 0;
}
$this->stats['facebook'] = !empty($response[0]['total_count']) ? $response[0]['total_count'] : $this->stats['facebook'];
}
发布于 2016-08-25 01:52:11
这是假设$this->url
的值是他们文章的URL,www.bloomberg.com
是他们的域,但您可以测试url中是否存在他们的域,然后将其设为0
,并在执行语句的其余部分之前返回:
function getFacebook() {
if(strstr($this->url,'www.bloomberg.com')) {
$this->stats['facebook'] = 0;
return;
}
// rest of code for this function...
https://stackoverflow.com/questions/39128432
复制相似问题