class SocialSharesCount { private $_networks; private $_url; private $_result = null; function __construct ($url,$networks = null) { $this->_networks = ($networks!=null)?$networks:$this->_getAllSocials(); $this->_url = urlencode($url); } private function _getSocial_moimir() { if (!($request = file_get_contents('http://connect.mail.ru/share_count?callback=1&url_list='.$this->_url.'&func=a'))) return false; $tmp = array(); if (!(preg_match('{\"shares\":(\d+),\"clicks\":(\d+)}',$request,$tmp))) return 0; else { return $tmp[1]; } } private function _getSocial_odnoklassniki() { if (!($request = file_get_contents('http://www.odnoklassniki.ru/dk?st.cmd=extOneClickLike&uid=odklocs0&ref='.$this->_url))) return false; $tmp = array(); if (!(preg_match("/^ODKL.updateCountOC\('[\d\w]+','(\d+)','(\d+)','(\d+)'\);$/i",$request,$tmp))) return false; return $tmp[1]; } private function _getSocial_yaru() { if (!($request = file_get_contents('http://wow.ya.ru/ajax/share-counter.xml?url='.$this->_url))) return false; $tmp = array(); if (!(preg_match("/(\s+)(\d+)(\s*)/i",$request,$tmp))) return false; return $tmp[2]; } private function _getSocial_buzz() { if (!($request = file_get_contents('http://www.google.com/buzz/api/buzzThis/buzzCounter?url='.$this->_url))) return false; $tmp = array(); if (!(preg_match('/^google_buzz_set_count\({"(.*?)":(\d+)}\);$/i',$request,$tmp))) return false; return $tmp[2]; } private function _getSocial_linkedin() { if (!($request = file_get_contents('http://www.linkedin.com/cws/share-count?url='.$this->_url))) return false; $tmp = array(); if (!(preg_match('/^IN.Tags.Share.handleCount\({"count":(\d+),"url":"(.*?)"}\);$/i',$request,$tmp))) return false; return $tmp[1]; } private function _getSocial_twitter() { if (!($request = file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url='.$this->_url))) return false; $twitter = json_decode($request); return ($twitter===NULL OR !isset($twitter->count))?false:$twitter->count; } private function _getSocial_facebook() { if (!($request = file_get_contents('http://graph.facebook.com/'.$this->_url))) return false; $fb = json_decode($request); return ($fb===NULL OR !isset($fb->shares))?0:$fb->shares; } private function _getSocial_vkontakte() { if (!($request = file_get_contents('http://vkontakte.ru/share.php?act=count&index=1&url='.$this->_url))) return false; $tmp = array(); if (!(preg_match('/^VK.Share.count\((\d+), (\d+)\);$/i',$request,$tmp))) return false; return $tmp[2]; } private function _getSocial_plusone() { if (!($request = file_get_contents('https://plusone.google.com/_/+1/fastbutton?url='.$this->_url))) return false; $tmp = array(); if (!(preg_match('/\