Need help with shariff-backend-php?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

127 Stars 35 Forks 406 Commits 6 Opened issues


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

Services available


Need anything else?

Contributors list

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.

Shariff Logo © 2014 Heise Zeitschriften Verlag

This document describes the PHP backend of Shariff.

Supported services

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


To run Shariff PHP Backend on your server you need one of these PHP versions:

  • 7.2
  • 7.3
  • 7.4

Older versions and HHVM are not supported.

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.

Take a look into the demo application in the

file and adjust the configuration as necessary.

The following configuration options are available:

| Key | Type | Description | |-------------|------|-------------| |

| Optional Cache class name. Has to implement
. Defaults to internal Laminas Cache. | |
| File cache settings, which are passed on to the Cache class. See description below. | |
| Domains for which share counts may be requested. If empty, all domains are allowed. | |
| 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

| Key | Type | Description | |-------------|------|-------------| |

| Time that the counts are cached (in seconds) | |
| Directory used for the cache. Default: system temp directory | |
| Name of cache adapter (e.g. Apc, Memcache, etc.) | |
| Options for the cache adapter |

These option apply for the default Cache class (

) only. If you implement custom caching, you can specify your own options.

Client options

The backend uses Guzzle as HTTP client. Guzzle has many options that you can set, e.g. timeout and connect_timeout. See for a detailed list. In order to set those options pass them in the json with the key "client".

| Key | Type | Description | |-------------|------|-------------| |

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

| Key | Type | Description | |-------------|------|-------------| |

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

| Key | Type | Description | |-------------|------|-------------| |

| the id of your facebook application | |
| 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
      // ... (see "Client options")
    'domains' => [
    'services' => [
    'Facebook' => [
      'app_id' => '1234567890',
      'secret' => 'terces'

Testing your installation

If the backend runs under
, calling the URL
should return a JSON structure with numbers in it, e.g.:

Shariff OO interface

If you need more control, you can invoke Shariff in your own PHP code. The following snippet should get you started.

are identical to those described above.
use Heise\Shariff\Backend;

$options = [ "domains" => ["", ""], "cache" => ["ttl" => 1], "services" => ["Facebook", "Reddit", "StumbleUpon", "Flattr", "Pinterest", "AddThis", "Buffer", "Vk"] ]; $shariff = new Backend($options); $counts = $shariff->get(""); echo $counts["facebook"];

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.