linpar/socialshare
Composer 安装命令:
composer require linpar/socialshare
包简介
Client library for the Social Share API
README 文档
README
SocialShare API can be used to fetch number of shares for a single or multiple URLs on social platforms.
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:
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:
{
"require" : {
"linpar/socialshare": "1.*"
}
}
And run Composer to update your dependencies:
$ 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
// 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
- Fetch number of shares/click/comments/likes of a URL on Facebook/Twitter (in case of shares).
$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:
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
)
- Fetch number of shares/click/comments/likes of multiple URLs on Facebook/Twitter (in case of shares).
$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:
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
)
)
- Fetch combined total number of shares/clicks/comments/likes of multiple URLs on Facebook/Twitter (in case of shares).
$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:
6524745
265615
1807874
1545368
TODO
- Add support for more platforms (Pinterest etc)
linpar/socialshare 适用场景与选型建议
linpar/socialshare 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「social」 「share」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 linpar/socialshare 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 linpar/socialshare 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 linpar/socialshare 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Improves silverstripes html meta data options.
LinkedIn integration for Social
A PSR-7 compatible library for making CRUD API endpoints
Autogenerated open graph images for your entries.
A helper module for pdf-print, print and social share functionality based on bootstrap to custom modules.
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-19