linpar / socialshare
Client library for the Social Share API
1.0.1
2014-11-20 18:28 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2025-01-14 05:03:49 UTC
README
SocialShare API can be used to fetch number of shares for a single or multiple URLs on social platforms.
Features
- Support for Facebook.
- Support for Twitter.
- Fetch data for multiple URLs.
- Fetch total number of shares/comments/clicks/likes of multiple URLs on Facebook.
- Fetch combined total number of shares/comments/clicks/likes of multiple URLs on Facebook.
- Fetch total number of shares of multiple URLs on Twitter.
Easy Installation
Install with git
From the command line switch to the directory where dompdf will reside and run the following commands:
git clone https://github.com/linpar/Socialshare-Client-PHP.git git submodule init git submodule update
Install with composer
To install with Composer, simply add the requirement to your composer.json
file:
{ "require" : { "linpar/socialshare": "1.*" } }
And run Composer to update your dependencies:
$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar update
Before you can use the Composer installation of SocialShare in your application you must include the Composer autoloader
// somewhere early in your project's loading, require the Composer autoloader // see: http://getcomposer.org/doc/00-intro.md require 'vendor/autoload.php';
Simple example
Note: To get API key, send an email to nitish.gundherva@nsitonline.in
- Fetch number of shares/click/comments/likes of a URL on Facebook/Twitter (in case of shares).
$socialShare = new SocialShare(API_KEY); print_r('<pre>'); print_r($socialShare->facebook->shares(array('http://github.com'))); // Replace facebook with twitter to calculate shares on Twitter print_r($socialShare->facebook->clicks(array('http://github.com'))); print_r($socialShare->facebook->comments(array('http://github.com'))); print_r($socialShare->facebook->likes(array('http://github.com')));
Output:
Array
(
[link] => http://github.com
[shares] => 13105
)
Array
(
[link] => http://github.com
[clicks] => 1
)
Array
(
[link] => http://github.com
[comments] => 3673
)
Array
(
[link] => http://github.com
[likes] => 5306
)
- Fetch number of shares/click/comments/likes of multiple URLs on Facebook/Twitter (in case of shares).
$socialShare = new SocialShare(API_KEY); print_r('<pre>'); print_r($socialShare->facebook->shares(array('http://github.com', 'http://google.com'))); // Replace facebook with twitter to calculate shares on Twitter print_r($socialShare->facebook->clicks(array('http://github.com', 'http://google.com'))); print_r($socialShare->facebook->comments(array('http://github.com', 'http://google.com'))); print_r($socialShare->facebook->likes(array('http://github.com', 'http://google.com')));
Output:
Array
(
[0] => Array
(
[link] => http://github.com
[shares] => 13105
)
[1] => Array
(
[link] => http://google.com
[shares] => 6511640
)
)
Array
(
[0] => Array
(
[link] => http://github.com
[clicks] => 1
)
[1] => Array
(
[link] => http://google.com
[clicks] => 265614
)
)
Array
(
[0] => Array
(
[link] => http://github.com
[comments] => 3673
)
[1] => Array
(
[link] => http://google.com
[comments] => 1804201
)
)
Array
(
[0] => Array
(
[link] => http://github.com
[likes] => 5306
)
[1] => Array
(
[link] => http://google.com
[likes] => 1540062
)
)
- Fetch combined total number of shares/clicks/comments/likes of multiple URLs on Facebook/Twitter (in case of shares).
$socialShare = new SocialShare(API_KEY); print_r('<pre>'); print_r($socialShare->facebook->totalShares(array('http://github.com', 'http://google.com')) ."\n"); // Replace facebook with twitter to calculate shares on Twitter print_r($socialShare->facebook->totalClicks(array('http://github.com', 'http://google.com')) ."\n"); print_r($socialShare->facebook->totalComments(array('http://github.com', 'http://google.com')) ."\n"); print_r($socialShare->facebook->totalLikes(array('http://github.com', 'http://google.com')) ."\n");
Output:
6524745
265615
1807874
1545368
TODO
- Add support for more platforms (Pinterest etc)