コード例 #1
0
ファイル: mashengine.php プロジェクト: a-i-ko93/ipl-foodblog
 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;
 }
コード例 #2
0
ファイル: mashengine.php プロジェクト: netmagik/netmagik
 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;
 }