PHPackages                             dunglas/php-socialshare - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dunglas/php-socialshare

AbandonedArchivedLibrary

dunglas/php-socialshare
=======================

Retrieve social networks share counts and share links

v1.0.0(10y ago)8010.7k221MITPHPPHP &gt;=5.3

Since Jan 16Pushed 10y ago9 watchersCompare

[ Source](https://github.com/dunglas/php-socialshare)[ Packagist](https://packagist.org/packages/dunglas/php-socialshare)[ Docs](https://dunglas.fr)[ RSS](/packages/dunglas-php-socialshare/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (10)Used By (1)

PHP SocialShare
===============

[](#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.

It currently supports:

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

[![Build Status](https://camo.githubusercontent.com/ff0c855c0284979661745018ff3ad8d373417f351aa841bbb45e81e501b75ef6/68747470733a2f2f7472617669732d63692e6f72672f64756e676c61732f7068702d736f6369616c73686172652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/dunglas/php-socialshare)[![SensioLabsInsight](https://camo.githubusercontent.com/d406a181c52ed0c135cfafb3b53e8fe9f8afc6e07ace740a1e6dba6dec3214ee/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31623565346261662d326436642d346464302d616131652d3963316637663430363139642f6d696e692e706e67)](https://insight.sensiolabs.com/projects/1b5e4baf-2d6d-4dd0-aa1e-9c1f7f40619d)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9257893880a6d515b3ff92da90c30908e722d4393267bf9c53dbbbf59994e670/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64756e676c61732f7068702d736f6369616c73686172652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dunglas/php-socialshare/?branch=master)[![HHVM Status](https://camo.githubusercontent.com/dff46d103e47273e01a6df035c3f7738dbb1841ef476b4ee36f61349ffd23c55/687474703a2f2f6868766d2e683463632e64652f62616467652f64756e676c61732f7068702d736f6369616c73686172652e737667)](http://hhvm.h4cc.de/package/dunglas/php-socialshare)

Key features
------------

[](#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
---------

[](#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.

ServiceOfficial way?FacebookyesTwitternoGooglenoLinkedInyesPinterestnoScoop.it!noStumbleUponnoGoogle returns only an estimate when there is more than 1000 shares (something like &gt;10K). PHP Social Share converts this estimate to an integer.

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

Installation
------------

[](#installation)

Use [Composer](https://getcomposer.org/) to install SocialShare:

```
composer require dunglas/php-socialshare

```

Usage
=====

[](#usage)

- [Simple example](examples/buttons.php)
- [Using SocialShare with Wordpress](https://dunglas.fr/2014/01/using-socialshare-with-wordpress-to-create-custom-social-networks-buttons/)
- [Twig extension](https://github.com/neemzy/share-extension)

Cache
-----

[](#cache)

SocialShare relies on the [Doctrine Cache](http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/caching.html) 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.

Delayed updates
---------------

[](#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

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

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.

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](http://php.net/manual/en/function.fastcgi-finish-request.php).

Other social networks
---------------------

[](#other-social-networks)

You can add support for new social networks by creating a class implementing the [`SocialShare\Provider\ProviderInterface`](src/SocialShare/Provider/ProviderInterface.php) interface. Pull Requests are appreciated.

They are using PHP SocialShare
------------------------------

[](#they-are-using-php-socialshare)

- [Lost In The Supermarket](http://lostinthesupermarket.fr/blog/)
- [Les-Tilleuls.coop](https://les-tilleuls.coop/actualites/)

Credits
-------

[](#credits)

This library has been written by [Kévin Dunglas](https://dunglas.fr) and [awesome contributors](https://github.com/dunglas/php-socialshare/graphs/contributors).

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 70.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~83 days

Recently: every ~164 days

Total

9

Last Release

3827d ago

Major Versions

v0.2.2 → v1.0.02015-11-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57224?v=4)[Kévin Dunglas](/maintainers/dunglas)[@dunglas](https://github.com/dunglas)

---

Top Contributors

[![dunglas](https://avatars.githubusercontent.com/u/57224?v=4)](https://github.com/dunglas "dunglas (40 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (7 commits)")[![nlemoine](https://avatars.githubusercontent.com/u/2526939?v=4)](https://github.com/nlemoine "nlemoine (4 commits)")[![morrelinko](https://avatars.githubusercontent.com/u/2414096?v=4)](https://github.com/morrelinko "morrelinko (3 commits)")[![neemzy](https://avatars.githubusercontent.com/u/1804389?v=4)](https://github.com/neemzy "neemzy (1 commits)")[![benatespina](https://avatars.githubusercontent.com/u/3951376?v=4)](https://github.com/benatespina "benatespina (1 commits)")[![DragonBe](https://avatars.githubusercontent.com/u/282825?v=4)](https://github.com/DragonBe "DragonBe (1 commits)")

---

Tags

socialsharecount

### Embed Badge

![Health badge](/badges/dunglas-php-socialshare/health.svg)

```
[![Health](https://phpackages.com/badges/dunglas-php-socialshare/health.svg)](https://phpackages.com/packages/dunglas-php-socialshare)
```

###  Alternatives

[social-links/social-links

PHP library to generate share buttons

112338.6k2](/packages/social-links-social-links)[yiimaker/yii2-social-share

Extension for sharing on social networks

48111.3k4](/packages/yiimaker-yii2-social-share)[fritzmg/contao-sharebuttons

Simple Contao extension to provide share buttons as a module and content element

1832.5k](/packages/fritzmg-contao-sharebuttons)[pdir/social-feed-bundle

Social feed extension for Contao CMS

1414.8k](/packages/pdir-social-feed-bundle)[ryannielson/shareable

A Laravel 4 package to make it easy to add social sharing buttons to your application.

222.8k](/packages/ryannielson-shareable)[yaro/soc-share

Social network share link builder

101.9k](/packages/yaro-soc-share)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
