2017 © Pedro Peláez
 

library socialworth

A simple PHP library for determining the popularity of a URL across social networks.

image

evansims/socialworth

A simple PHP library for determining the popularity of a URL across social networks.

  • Tuesday, July 15, 2014
  • by evansims
  • Repository
  • 11 Watchers
  • 119 Stars
  • 7,240 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 29 Forks
  • 5 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Socialworth

Latest Stable Version Build Status Coverage Status License, (*1)

A simple PHP library for determining the popularity of a given URL by querying social network APIs., (*2)

It presently supports: - Twitter (counts mentions and retweets) - Facebook (counts likes, comments and shares) - Google+ (+1s) - Pinterest (shares) - Reddit (counts submitted stories and upvotes) - StumbleUpon views - LinkedIn shares - ~~Hacker News~~ API service is currently offline. - ~~Mozscape Backlinks~~ Retired., (*3)

There a variety of use cases for this library; generating a list of your blog's most popular articles for optimizing placement, or featuring social network counters on your pages without relying on bloated external JavaScript includes., (*4)

Installation

To add this package as a dependency for your project, simply add evansims/socialworth to your project's composer.json file. Here is an example of a minimal composer.json file:, (*5)

{
    "require": {
        "evansims/socialworth": "*"
    }
}

Then run composer install to install the library. Composer generates a vendor/autoload.php file that you'll need to include in your project before invoking Socialworth:, (*6)

require 'vendor/autoload.php';

Usage

To query all supported services for a URL:, (*7)

<?php
use Evansims\Socialworth;

$socialworth = new Socialworth('https://github.com/');
var_dump($socialworth->all());
?>

Alternatively you can query just one service:, (*8)

<?php
use Evansims\Socialworth;

var_dump(Socialworth::twitter('https://github.com/'));
?>

Or leave out specific services from your query:, (*9)

<?php
use Evansims\Socialworth;

$socialworth = new Socialworth('https://github.com/');
$socialworth->linkedin = false;

var_dump($socialworth->all());
?>

The all() method will return an object that you can use to grab individual service results or find the combined popularity from the services:, (*10)

<?php
use Evansims\Socialworth;

$socialworth = new Socialworth('https://github.com/');
$response = $socialworth->all();

var_dump($response->total); // Total likes, shares, upvotes, etc.
var_dump($response->reddit); // Just shares and upvotes from reddit.
var_dump($response->twitter); // Just mentions, retweets and shares on Twitter.
?>

Demo Script

A demo script is provided that allows you to query the library from your browser, or the command line., (*11)

To call the script from the command line ..., (*12)

$ php demo.php https://github.com/

Or, to query individual services ..., (*13)

$ php demo.php --twitter --facebook https://github.com/

If the demo script is accessible from your web server, you can pass a url ..., (*14)

http://localhost/path/to/demo.php?url=https://github.com/

Whether from the CLI or the browser, you will receive a JSON object back., (*15)

{
    "total": 48217,
    "twitter": 26582,
    "facebook": 15284,
    "pinterest": 157,
    "reddit": 5,
    "googleplus": 6049,
    "stumbleupon": 297,
    "linkedin": 0
}

This work was inspired by Jonathan Moore's gist: https://gist.github.com/2640302, (*16)

The Versions

15/07 2014

dev-master

9999999-dev http://github.com/evansims/socialworth

A simple PHP library for determining the popularity of a URL across social networks.

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • lib-curl *

 

The Development Requires

analytics facebook twitter linkedin reddit google plus popularity pinterest social network stumbleupon hackernews

03/05 2014

2.0.0

2.0.0.0 http://github.com/evansims/socialworth

A simple PHP library for determining the popularity of a URL across social networks.

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • lib-curl *

 

The Development Requires

analytics facebook twitter linkedin reddit google plus popularity pinterest social network stumbleupon hackernews