2017 © Pedro Peláez
 

library shariff

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

image

heise/shariff

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  • Wednesday, May 30, 2018
  • by pmb0
  • Repository
  • 37 Watchers
  • 106 Stars
  • 38,219 Installations
  • PHP
  • 11 Dependents
  • 0 Suggesters
  • 35 Forks
  • 2 Open issues
  • 36 Versions
  • 14 % Grown

The README.md

Shariff PHP Backend Build Status Code Climate

Shariff is used to determine how often a page is shared in social media, but without generating requests from the displaying page to the social sites., (*1)

Shariff Logo © 2014 Heise Zeitschriften Verlag, (*2)

This document describes the PHP backend of Shariff., (*3)

Supported services

  • Buffer
  • Facebook
  • Pinterest
  • Reddit
  • StumbleUpon
  • Xing
  • Vk

Requirements

To run Shariff PHP Backend on your server you need one of these PHP versions:, (*4)

  • 7.4
  • 8.0
  • 8.1
  • 8.2

Older versions and HHVM are not supported., (*5)

Installing the Shariff backend on your own server

To run Shariff under a certain URL, unzip the release zip file into a directory under the document root of your web server., (*6)

Take a look into the demo application in the index.php file and adjust the configuration as necessary., (*7)

The following configuration options are available:, (*8)

Key Type Description
cacheClass string Optional Cache class name. Has to implement Heise\Shariff\CacheInterface. Defaults to internal Laminas Cache.
cache object File cache settings, which are passed on to the Cache class. See description below.
domains array Domains for which share counts may be requested. If empty, all domains are allowed.
services array List of services to be enabled. See Supported services.
Cache settings:

By default Shariff uses the Filesystem cache. By specifying a different adapter from Laminas\Cache\Storage\Adapter you can tell Shariff to use another cache. Also you can specify options for that cache adapter, (*9)

Key Type Description
ttl integer Time that the counts are cached (in seconds)
cacheDir string Directory used for the cache. Default: system temp directory
adapter string Name of cache adapter (e.g. Apc, Memcache, etc.) br/You can find an overview of all available Adapters here. It is required to install these separately through composer
adapterOptions object Options for the cache adapter

These option apply for the default Cache class (LaminasCache) only. If you implement custom caching, you can specify your own options., (*10)

Client options

The backend uses Guzzle as HTTP client. Guzzle has many options that you can set, e.g. timeout and connect_timeout. See http://docs.guzzlephp.org/en/latest/request-options.html for a detailed list. In order to set those options pass them in the json with the key "client"., (*11)

Key Type Description
client object Guzzle request options
Service Settings

To pass config options to a service, you can add them to the json as well under the name of the service. Currently only the Facebook service has options for an facebook application id and client secret in order to use the graph api id method to get the current share count., (*12)

Key Type Description
servicename object options for the service
Facebook service options

To use the graph api id method to fetch the share count you need to set up an application at facebook.com and pass in the application id and client secret to the options. It seems that the id method returns the most current share count, but it can be only used with an registered application., (*13)

Key Type Description
app_id string the id of your facebook application
secret string the client secret of your facebook application
Full config example
use Heise\Shariff\LaminasCache;
/**
 * Sample configuration
 *
 * @var array
 */
private static $configuration = [
    'cacheClass' => 'Heise\\Shariff\\LaminasCache',
    'cache' => [
        'ttl' => 60,
        'cacheDir' => '/tmp/shariff/cache',
        'adapter' => 'Filesystem',
        'adapterOptions' => [
          // ...
        ]
    ],
    'client' => [
      'timeout' => 4.2,
      'headers' => [
        'User-Agent' => 'shariff/1.0',
      ]
      // ... (see "Client options")
    ],
    'domains' => [
        'www.heise.de',
        'www.ct.de'
    ],
    'services' => [
        'Facebook',
        'Reddit',
        'StumbleUpon',
        'Pinterest',
        'Xing',
        'Buffer',
        'Vk'
    ],
    'Facebook' => [
      'app_id' => '1234567890',
      'secret' => 'terces'
    ]
];

Testing your installation

If the backend runs under http://example.com/my-shariff-backend/, calling the URL http://example.com/my-shariff-backend/?url=http%3A%2F%2Fwww.example.com should return a JSON structure with numbers in it, e.g.:, (*14)

{"facebook":1452,"reddit":7,"stumbleupon":4325,"pinterest":3,"buffer":29,"vk":326}

Shariff OO interface

If you need more control, you can invoke Shariff in your own PHP code. The following snippet should get you started. $options are identical to those described above., (*15)

use Heise\Shariff\Backend;

$options = [
    "domains"  => ["www.heise.de", "www.ct.de"],
    "cache"    => ["ttl" => 1],
    "services" => ["Facebook", "Reddit", "StumbleUpon", "Pinterest", "Buffer", "Vk"]
];
$shariff = new Backend($options);
$counts = $shariff->get("https://www.heise.de/");
echo $counts["facebook"];

The Versions

30/05 2018

dev-master

9999999-dev https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

30/05 2018

7.1.3

7.1.3.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

25/05 2018

7.1.2

7.1.2.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

01/03 2018

dev-docker

dev-docker https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

23/02 2018

7.1.1

7.1.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

26/01 2018

7.1.0

7.1.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

04/12 2017

7.0.2

7.0.2.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

20/11 2017

7.0.1

7.0.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

30/03 2017

7.0.0

7.0.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

07/02 2017

6.0.1

6.0.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

16/08 2016

6.0.0

6.0.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

19/07 2016

5.2.4

5.2.4.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

01/04 2016

5.2.3

5.2.3.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

31/03 2016

5.2.2

5.2.2.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

31/03 2016

5.2.1

5.2.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

24/02 2016

5.2.0

5.2.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

18/02 2016

5.1.0

5.1.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

02/02 2016

5.0.0

5.0.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

31/01 2016

4.1.0

4.1.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

26/01 2016

4.0.2

4.0.2.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

10/01 2016

4.0.1

4.0.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

06/01 2016

4.0.0

4.0.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philipp Busse

heise shariff social buttons

23/11 2015

2.0.0

2.0.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

08/09 2015

1.5.2

1.5.2.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

12/06 2015

1.5.1

1.5.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

27/05 2015

1.5.0

1.5.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

26/02 2015

1.4.1

1.4.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

04/02 2015

1.4.0

1.4.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

03/02 2015

1.3.0

1.3.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

16/01 2015

1.2.0

1.2.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

13/01 2015

1.1.1

1.1.1.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons

12/01 2015

1.1.0

1.1.0.0 https://github.com/heiseonline/shariff-backend-php

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

  Sources   Download

MIT

The Requires

 

by Philipp Busse

heise shariff social buttons