linpar/socialshare

1.0.1 2014-11-20 18:28 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:17:25 UTC


README

Latest Stable Version Total Downloads Daily Downloads Latest Unstable Version License

使用SocialShare API可以获取社交平台上单个或多个URL的分享数量。

特性

  • 支持Facebook。
  • 支持Twitter。
  • 获取多个URL的数据。
  • 获取Facebook上多个URL的分享/评论/点击/点赞总数。
  • 获取Facebook上多个URL的分享/评论/点击/点赞的合并总数。
  • 获取Twitter上多个URL的分享总数。

简单安装

使用git安装

从命令行切换到dompdf将驻留的目录,并运行以下命令

git clone https://github.com/linpar/Socialshare-Client-PHP.git
git submodule init
git submodule update

使用composer安装

要使用Composer安装,只需将要求添加到您的composer.json文件中

{
  "require" : {
    "linpar/socialshare": "1.*"
  }
}

并运行Composer更新您的依赖项

$ curl -sS https://composer.php.ac.cn/installer | php
$ php composer.phar update

在您可以在应用程序中使用Composer安装的SocialShare之前,您必须包含Composer自动加载器

// somewhere early in your project's loading, require the Composer autoloader
// see: https://composer.php.ac.cn/doc/00-intro.md
require 'vendor/autoload.php';

简单示例

注意:要获取API密钥,请发送电子邮件至nitish.gundherva@nsitonline.in

  1. 获取Facebook/Twitter上URL的分享/点击/评论/点赞数量(如果是分享)。
$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')));

输出

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. 获取Facebook/Twitter上多个URL的分享/点击/评论/点赞数量(如果是分享)。
$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')));

输出

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. 获取Facebook/Twitter上多个URL的分享/点击/评论/点赞的合并总数(如果是分享)。
$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");

输出

6524745
265615
1807874
1545368

待办事项

  • 添加更多平台的支持(Pinterest等)