A PHP class that looks up the number of times a given URL has been shared on major social networks.
Requires PHP > 4 with curl extension.
Download and include the PHP class file.
To instantiate, you may use the class constructor
$SharedCount = new SharedCount('http://blogger.com/my-blog/my-article');
The SharedCount class accepts a single parameter:
- $url (string) - The URL to look up
set_url ( string $url ) Updates the current URL in the instance
$SharedCount->set_url('http://blogger.com/my-blog/my-article-2');
get_count ( string $social_network ) Get the shared count of the URL for a social_network
Available values are 'all', 'pinterest', 'twitter', 'facebook_share', 'facebook_like', 'linkedin', 'googleplus'*
echo $SharedCount->get_count('facebook_share');
get_sum_of ( array $social_network_arr ) Get the total shared counts of the URL for a given array of social networks
Available values are 'pinterest', 'twitter', 'facebook_share', 'facebook_like', 'linkedin', 'googleplus'. If you want to get ALL available social networks, use get_count('all')
instead.
echo $SharedCount->get_sum_of(array('facebook_share', 'facebook_like'));
To output the shared counts of all provided social networks
echo $SharedCount->get_count('all');
Copyright (c) 2014
Licensed under the MIT License.