Giter Site home page Giter Site logo

uwej711 / shariff-backend-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from heiseonline/shariff-backend-php

0.0 3.0 0.0 1.26 MB

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

Home Page: http://ct.de/-2467514

Shell 0.53% PHP 99.47%

shariff-backend-php's Introduction

Shariff PHP Backend Build Status

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. The following backends are also available:

Supported services

  • Facebook
  • Flattr
  • GooglePlus
  • LinkedIn
  • Pinterest
  • Reddit
  • StumbleUpon
  • Twitter
  • Xing

Requirements

To run Shariff PHP Backend on your server you need:

  • PHP 5.4 or greater

Installing the Shariff backend on you own server

To run Shariff under a certain URL, unzip the release zip file and put contents of build/ into a directory under the document root of your web server.

This zip file contains contains a configuration file shariff.json. The following configuration options are available:

Key Type Description
cache object File cache settings described below
domain string Domain for which share counts may be requested
services array List of services to be enabled. See Supported services.
Cache settings:
Key Type Description
ttl integer Time that the counts are cached (in seconds)
cacheDir string Directory used for the cache. Default: system temp directory
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
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.

Key Type Description
app_id string the id of your facebook application
secret string the client secret of your facebook application

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

{"facebook":1452,"twitter":404,"googleplus":23,"linkedin":118,"reddit":7,"stumbleupon":4325,"flattr":0,"pinterest":3}

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.

use Heise\Shariff\Backend;

$options = [
	"domain"   => 'www.heise.de',
	"cache"    => ["ttl" => 1],
	"services" => ["Facebook", "GooglePlus", "Twitter", "LinkedIn", "Reddit", "StumbleUpon", "Flattr", "Pinterest"]
]
$shariff = Backend->new($options);
$counts = $backend->get("http://www.heise.de/");
echo $counts["facebook"];

shariff-backend-php's People

Contributors

ipa01 avatar lbehm avatar markusschwarz avatar ooxi avatar pmb0 avatar sehkunde avatar uwej711 avatar xiut avatar yanniks avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.