예제 #1
0
파일: twitter.php 프로젝트: xb11/Website
 /**
  * Get the number of times this URL has been shared
  * @param	Model_Blog_Post		The post
  */
 public function share_count(Model_Blog_Post $post)
 {
     $url = self::COUNT_URL . '?' . http_build_query(array('url' => $post->url(true)));
     $data = json_decode(file_get_contents($url));
     if (empty($data) || empty($data->count)) {
         return 0;
     }
     return $data->count;
 }
예제 #2
0
파일: facebook.php 프로젝트: xb11/Website
 /**
  * Get the number of times this URL has been shared
  * @param	Model_Blog_Post		The post
  */
 public function share_count(Model_Blog_Post $post)
 {
     // Get the count using FQL. Returns *both* like count and share count.
     $query = sprintf(self::LINK_QUERY, $post->url(true));
     $url = self::QUERY_URL . '?' . http_build_query(array('query' => $query));
     $data = simplexml_load_file($url);
     if (empty($data) || empty($data->link_stat) || empty($data->link_stat->total_count)) {
         return 0;
     }
     return (int) $data->link_stat->total_count;
 }
예제 #3
0
파일: linkedin.php 프로젝트: xb11/Website
 /**
  * Get the number of times this URL has been shared
  * @param	Model_Blog_Post		The post
  */
 public function share_count(Model_Blog_Post $post)
 {
     $url = self::API_URL . '?' . http_build_query(array('url' => $post->url(true)));
     $data = file_get_contents($url);
     // Ugly hack to get JSON data from the JavaScript method call
     $data = str_replace(array('IN.Tags.Share.handleCount(', ');'), '', $data);
     $data = json_decode($data);
     if (empty($data)) {
         return 0;
     }
     return $data->count;
 }
예제 #4
0
파일: reddit.php 프로젝트: xb11/Website
 /**
  * Get the number of times this URL has been shared
  * @param	Model_Blog_Post		The post
  */
 public function share_count(Model_Blog_Post $post)
 {
     $total = 0;
     $url = self::API_URL . '?' . http_build_query(array('url' => $post->url(true)));
     $data = json_decode(file_get_contents($url));
     if (empty($data) || empty($data->data) || empty($data->data->children)) {
         return 0;
     }
     // Need to add up the points in every submission of this URL
     foreach ($data->data->children as $child) {
         $total += $child->data->score;
     }
     return $total;
 }