定制 dunglas/php-socialshare 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dunglas/php-socialshare

最新稳定版本:v1.0.0

Composer 安装命令:

composer require dunglas/php-socialshare

包简介

Retrieve social networks share counts and share links

README 文档

README

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 SensioLabsInsight Scrutinizer Code Quality HHVM Status

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?
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.

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.

dunglas/php-socialshare 适用场景与选型建议

dunglas/php-socialshare 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.78k 次下载、GitHub Stars 达 82, 最近一次更新时间为 2014 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「social」 「share」 「count」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dunglas/php-socialshare 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dunglas/php-socialshare 我们能提供哪些服务?
定制开发 / 二次开发

基于 dunglas/php-socialshare 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10.78k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 83
  • 点击次数: 20
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 82
  • Watchers: 9
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-16