2017 © Pedro Peláez
 

library php-socialshare

Retrieve social networks share counts and share links

image

dunglas/php-socialshare

Retrieve social networks share counts and share links

  • Wednesday, May 4, 2016
  • by dunglas
  • Repository
  • 10 Watchers
  • 82 Stars
  • 2,334 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 23 Forks
  • 4 Open issues
  • 10 Versions
  • 31 % Grown

The README.md

PHP SocialShare

SocialShare is a PHP library allowing to retrieve the number of shares of URLs on major social networks. It is also able to generate valid sharing links., (*1)

It currently supports:, (*2)

  • Facebook
  • Twitter
  • Google Plus
  • Pinterest
  • LinkedIn
  • Scoop.it!
  • StumbleUpon
  • Tumblr

Build Status SensioLabsInsight Scrutinizer Code Quality HHVM Status, (*3)

Key features

  • Speed: counts are retrieved server-side and cached; no JavaScript SDK loading; no HTTP request from your visitor's browser to social networks
  • Privacy: therefore, no data from your visitors is send to social networks, their privacy is respected
  • Customization: there is no need to use official social networks buttons, you can create beautiful custom buttons displaying the number of shares

Drawbacks

For most social networks, the number of shares is retrieved through services not officially approved by social networks. These services can be shut down without warning., (*4)

Service Official way?
Facebook yes
Twitter no
Google no
LinkedIn yes
Pinterest no
Scoop.it! no
StumbleUpon no

Google returns only an estimate when there is more than 1000 shares (something like >10K). PHP Social Share converts this estimate to an integer., (*5)

Tumblr share count cannot be retrieved for an arbitrary URL, and is therefore unavailable through this library., (*6)

Installation

Use Composer to install SocialShare:, (*7)

composer require dunglas/php-socialshare

Usage

Cache

SocialShare relies on the Doctrine Cache library to store data retrieved from social networks. Doctrine Cache supports a lot of caching systems including but not limited to file, Memcache, MongoDB, Redis and APC. Use the one that suit your needs., (*8)

Delayed updates

When the third parameter of the \SocialShare\SocialShare::getShares() method is set to true, the number of share counts is never retrieved from social networks: If a value is already in the cache (how old it is doesn't matter) it is used, otherwise 0 is returned, (*9)

To force the update of share counts, the \SocialShare\SocialShare::update() method must be called., (*10)

Thanks to this tweak, HTTP requests retrieving shares counts from social networks will be issued after the page load. Of course, only the next visitor will see updated counts, but it allows fast pages load even in the worst case: when the data must be updated from social networks servers., (*11)

If you use PHP FPM, the call to this method should be done after the end of the network connection with the client using the fastcgi_finish_request() function., (*12)

Other social networks

You can add support for new social networks by creating a class implementing the SocialShare\Provider\ProviderInterface interface. Pull Requests are appreciated., (*13)

They are using PHP SocialShare

Credits

This library has been written by Kévin Dunglas and awesome contributors., (*14)

The Versions

04/05 2016

dev-master

9999999-dev https://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

17/11 2015

v1.0.0

1.0.0.0 https://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

03/04 2015

v0.2.2

0.2.2.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

19/03 2014

0.2.1

0.2.1.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

14/02 2014

v0.2.0

0.2.0.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

29/01 2014

v0.1.4

0.1.4.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

27/01 2014

v0.1.3

0.1.3.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

17/01 2014

v0.1.2

0.1.2.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

17/01 2014

v0.1.1

0.1.1.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count

16/01 2014

v0.1.0

0.1.0.0 http://dunglas.fr

Retrieve social networks share counts and share links

  Sources   Download

MIT

The Requires

 

The Development Requires

social share count