linpar/socialshare 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

linpar/socialshare

Composer 安装命令:

composer require linpar/socialshare

包简介

Client library for the Social Share API

README 文档

README

Latest Stable Version Total Downloads Daily Downloads Latest Unstable Version License

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

  1. 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
)
  1. 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
        )

)
  1. 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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-19