public function getSharesALL() { global $mashsb_options; $fb_mode = isset($mashsb_options['facebook_count_mode']) ? $mashsb_options['facebook_count_mode'] : ''; $post_data = null; //$user_data = null; $headers = null; $options = array(CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE); $RollingCurlX = new RollingCurlX(8); // max 10 simultaneous downloads $RollingCurlX->setOptions($options); switch ($fb_mode) { case $fb_mode === 'likes': $RollingCurlX->addRequest("https://api.facebook.com/method/links.getStats?format=json&urls=" . $this->url, $post_data, array($this, 'getCount'), array('facebook_likes'), $headers); break; case $fb_mode === 'total': $RollingCurlX->addRequest("https://api.facebook.com/method/links.getStats?format=json&urls=" . $this->url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers); break; default: $RollingCurlX->addRequest("https://api.facebook.com/method/links.getStats?format=json&urls=" . $this->url, $post_data, array($this, 'getCount'), array('facebook_shares'), $headers); } $RollingCurlX->addRequest("http://urls.api.twitter.com/1/urls/count.json?url=" . $this->url, $post_data, array($this, 'getCount'), array('twitter'), $headers); $RollingCurlX->addRequest("https://www.linkedin.com/countserv/count/share?format=json&url=" . $this->url, $post_data, array($this, 'getCount'), array('linkedin'), $headers); $RollingCurlX->addRequest("http://www.stumbleupon.com/services/1.01/badge.getinfo?url=" . $this->url, $post_data, array($this, 'getCount'), array('stumbleupon'), $headers); $RollingCurlX->addRequest("https://plusone.google.com/_/+1/fastbutton?url=" . $this->url, $post_data, array($this, 'getCount'), array('google'), $headers); $RollingCurlX->addRequest("http://api.pinterest.com/v1/urls/count.json?url=" . $this->url, $post_data, array($this, 'getCount'), array('pinterest'), $headers); //$RollingCurlX->addRequest("http://feeds.delicious.com/v2/json/urlinfo/data?url=" . $this->url, $post_data, array($this, 'getCount'), array('delicious'), $headers); //$RollingCurlX->addRequest("http://www.reddit.com/api/info.json?&url=" . $this->url, $post_data, array($this, 'getCount'), array('reddit'), $headers); $RollingCurlX->addRequest("https://api.bufferapp.com/1/links/shares.json?url=" . $this->url, $post_data, array($this, 'getCount'), array('buffer'), $headers); $RollingCurlX->addRequest("https://vk.com/share.php?act=count&index=1&url=" . $this->url, $post_data, array($this, 'getCount'), array('vk'), $headers); $RollingCurlX->execute(); //$data = json_encode($this->data); // This return an json string instead $data = $this->data; // return the total count //return $data->shares->total; return $data; }
public function getSharesALL() { global $mashsb_options; $fb_mode = isset($mashsb_options['facebook_count_mode']) ? $mashsb_options['facebook_count_mode'] : 'total'; $post_data = null; $headers = null; $options = array(CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE); $RollingCurlX = new RollingCurlX(10); // max 10 simultaneous downloads $RollingCurlX->setOptions($options); switch ($fb_mode) { case $fb_mode === 'likes': if (isset($mashsb_options['cumulate_http_https'])) { $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->https_scheme_url, $post_data, array($this, 'getCount'), array('facebook_likes'), $headers); $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('facebook_likes'), $headers); } else { } $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->url, $post_data, array($this, 'getCount'), array('facebook_likes'), $headers); break; case $fb_mode === 'total': if (isset($mashsb_options['cumulate_http_https'])) { $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->https_scheme_url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers); $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers); } else { $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers); } break; default: if (isset($mashsb_options['cumulate_http_https'])) { $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->https_scheme_url, $post_data, array($this, 'getCount'), array('facebook_shares'), $headers); $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('facebook_shares'), $headers); } else { $RollingCurlX->addRequest("http://graph.facebook.com/?id=" . $this->url, $post_data, array($this, 'getCount'), array('facebook_shares'), $headers); } } if (isset($mashsb_options['cumulate_http_https'])) { $RollingCurlX->addRequest("http://public.newsharecounts.com/count.json?url=" . $this->https_scheme_url, $post_data, array($this, 'getCount'), array('twitter'), $headers); $RollingCurlX->addRequest("http://public.newsharecounts.com/count.json?url=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('twitter'), $headers); } else { $RollingCurlX->addRequest("http://public.newsharecounts.com/count.json?url=" . $this->url, $post_data, array($this, 'getCount'), array('twitter'), $headers); } $RollingCurlX->addRequest("https://www.linkedin.com/countserv/count/share?format=json&url=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('linkedin'), $headers); $RollingCurlX->addRequest("http://www.stumbleupon.com/services/1.01/badge.getinfo?url=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('stumbleupon'), $headers); $RollingCurlX->addRequest("https://plusone.google.com/_/+1/fastbutton?url=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('google'), $headers); $RollingCurlX->addRequest("http://api.pinterest.com/v1/urls/count.json?url=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('pinterest'), $headers); $RollingCurlX->addRequest("https://api.bufferapp.com/1/links/shares.json?url=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('buffer'), $headers); $RollingCurlX->addRequest("https://vk.com/share.php?act=count&index=1&url=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('vk'), $headers); $RollingCurlX->execute(); //$data = json_encode($this->data); // This return an json string instead $data = $this->data; // return the total count //return $data->shares->total; return $data; }
<?php require_once './rollingcurlx.class.php'; $assetsFolder = __DIR__ . '/downloaded-assets'; $photos = array(); $data_file = $assetsFolder . '/data.json'; if (!file_exists($data_file)) { exit("Data file {$data_file} not found\n"); } $data = json_decode(file_get_contents($data_file)); if (json_last_error()) { exit("Data file {$data_file} parsing failed\n"); } $RCX = new RollingCurlX(10); $RCX->setCallback('cb'); foreach ($data as $id => $post) { if (!isset($post->full_picture)) { $photos[$post->id] = 'post has no image'; continue; } $file_name = getFileNameFromURL($post->full_picture); $file_path = $assetsFolder . "/photos/{$file_name}"; if (!file_exists($file_path)) { $RCX->addRequest($post->full_picture, NULL, NULL, array('id' => $id, 'path' => $file_path)); $photos[$post->id] = 'image download intitiated'; } else { $photos[$post->id] = 'image exists on disk'; } } $RCX->execute(); print_r($photos);