Get support for dunglas/php-socialshare
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
dunglas/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:
- Google Plus
- Scoop.it!
- StumbleUpon
- Tumblr
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.
Service | Official way? |
---|---|
yes | |
no | |
no | |
yes | |
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.
Tumblr share count cannot be retrieved for an arbitrary URL, and is therefore unavailable through this library.
Installation
Use Composer to install SocialShare:
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.
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.
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.
They are using PHP SocialShare
Credits
This library has been written by Kévin Dunglas and awesome contributors.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2