seq_share_count.php in Share Buttons, Related Posts, Content Analytics - Shareaholic 8
File
lib/social-share-counts/seq_share_count.php
View source
<?php
require_once 'share_count.php';
class ShareaholicSeqShareCount extends ShareaholicShareCount {
public function get_counts() {
$services_length = count($this->services);
$config = self::get_services_config();
$response = array();
$response['status'] = 200;
for ($i = 0; $i < $services_length; $i++) {
$service = $this->services[$i];
if (!isset($config[$service])) {
continue;
}
if (isset($config[$service]['prepare'])) {
$this
->{$config[$service]['prepare']}($this->url, $config);
}
$timeout = isset($config[$service]['timeout']) ? $config[$service]['timeout'] : 1;
$timeout = isset($this->options['timeout']) ? $this->options['timeout'] : $timeout;
$options = array(
'method' => $config[$service]['method'],
'timeout' => $timeout,
'headers' => isset($config[$service]['headers']) ? $config[$service]['headers'] : array(),
'body' => isset($config[$service]['body']) ? $config[$service]['body'] : NULL,
);
$result = ShareaholicHttp::send(str_replace('%s', $this->url, $config[$service]['url']), $options);
if (!$result) {
$response['status'] = 500;
}
$callback = $config[$service]['callback'];
$counts = $this
->{$callback}($result);
if (is_numeric($counts)) {
$response['data'][$service] = $counts;
}
$this->raw_response[$service] = $result;
}
return $response;
}
}
Classes
Name |
Description |
ShareaholicSeqShareCount |
A class that implements ShareaholicShareCounts
This class will get the share counts by calling
the social services sequentially |