Created
January 9, 2015 23:58
-
-
Save ibes/24258dbb0eb1944eca94 to your computer and use it in GitHub Desktop.
Count shows shares + likes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Heise\Shariff\Backend; | |
class Facebook extends Request implements ServiceInterface | |
{ | |
public function getName() | |
{ | |
return 'facebook'; | |
} | |
public function getRequest($url) | |
{ | |
$facebookURL = 'https://api.facebook.com/method/fql.query'; | |
$facebookURL .= '?format=json'; | |
$facebookURL .= '&query=select share_count,like_count from link_stat where url="' . $url . '"'; | |
return $this->createRequest($facebookURL); | |
} | |
public function extractCount($data) | |
{ | |
return (int)$data[0]['share_count'] + (int)$data[0]['like_count']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment