Skip to content

Instantly share code, notes, and snippets.

@ibes
Created January 9, 2015 23:58
Show Gist options
  • Save ibes/24258dbb0eb1944eca94 to your computer and use it in GitHub Desktop.
Save ibes/24258dbb0eb1944eca94 to your computer and use it in GitHub Desktop.
Count shows shares + likes
<?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