2017 © Pedro Peláez
 

library socialshare

Client library for the Social Share API

image

linpar/socialshare

Client library for the Social Share API

  • Friday, January 2, 2015
  • by linpar
  • Repository
  • 0 Watchers
  • 1 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

SocialShare API PHP Client

Latest Stable Version Total Downloads Daily Downloads Latest Unstable Version License, (*1)

SocialShare API can be used to fetch number of shares for a single or multiple URLs on social platforms., (*2)

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:, (*3)

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:, (*4)

{
  "require" : {
    "linpar/socialshare": "1.*"
  }
}

And run Composer to update your dependencies:, (*5)

$ 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, (*6)

// 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, (*7)

1) Fetch number of shares/click/comments/likes of a URL on Facebook/Twitter (in case of shares)., (*8)

$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:, (*9)

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
)

2) Fetch number of shares/click/comments/likes of multiple URLs on Facebook/Twitter (in case of shares)., (*10)

$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:, (*11)

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
        )

)

3) Fetch combined total number of shares/clicks/comments/likes of multiple URLs on Facebook/Twitter (in case of shares)., (*12)

$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:, (*13)

6524745
265615
1807874
1545368

TODO

  • Add support for more platforms (Pinterest etc)

The Versions

02/01 2015

dev-master

9999999-dev https://github.com/linpar/Socialshare-Client-Php

Client library for the Social Share API

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

api social share

20/11 2014

1.0.1

1.0.1.0 https://github.com/linpar/Socialshare-Client-Php

Client library for the Social Share API

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

api social share

20/11 2014

1.0.0

1.0.0.0 https://github.com/linpar/Socialshare-Client-Php

Client library for the Social Share API

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

api social share