Giter Club home page Giter Club logo

socialproof's Introduction

SocialProof

Latest Stable Version Total Downloads

What is SocialProof?

SocialProof is a fluent interface for fetching followers / fans from various social media platforms using their internal API. It handles all API requests asynchronous using Guzzle and catches API exceptions / errors with a user-definable default value.

Features

  • Simple, fluent syntax for handling credentials / configuration.
  • Completely asynchronous using Guzzle's getAsync().
  • User-definable default values when an API request fails.
  • Simple debugging when configuring.
  • Automatically handles OAuth when fetching from API's such as Twitter.
  • Easily extendable and all PR's are very welcome. ❤️

Current Platforms

All pull requests for additional platforms are greatly appreciated. Please use the existing Providers as an example.

Requirements

Installation

Install via Composer:

composer require log1x/socialproof

Usage

SocialProof is incredibly easy to use, but caching values and storing them appropriately to not hit API limits / affect performance is up to the end-user. For WordPress, an example would be using the Transients API with an expiration of every 24 hours and the Options API for a fallback value along with ->setDefault() in the event an API request fails after your transient expires.

Facebook

use SocialProof\SocialProof;

return SocialProof::social()
  ->facebook()
      ->setUsername('example')
      ->setToken('XXXXXXXXXXXXXXXXXXXXXXXX')
  ->get();

See here to generate a token for Facebook.

Twitter

use SocialProof\SocialProof;

return SocialProof::social()
  ->twitter()
      ->setUsername('username')
      ->setConsumerKey('XXXXXXXXXXXXXXXXXXXXXXXX')
      ->setConsumerSecret('XXXXXXXXXXXXXXXXXXXXXXXX')
      ->setToken('XXXXXXXXXXXXXXXXXXXXXXXX')
      ->setTokenSecret('XXXXXXXXXXXXXXXXXXXXXXXX')
  ->get();

Instagram

use SocialProof\SocialProof;

return SocialProof::social()
  ->instagram()
      ->setToken('XXXXXXXXXXXXXXXXXXXXXXXX')
  ->get();

Pinterest

use SocialProof\SocialProof;

return SocialProof::social()
  ->pinterest()
      ->setUsername('username')
  ->get();

LinkedIn

use SocialProof\SocialProof;

return SocialProof::social()
  ->linkedin()
      ->setUsername('username')
      ->setToken('XXXXXXXXXXXXXXXXXXXXXXXX')
  ->get();

Configuration

SocialProof::social() accepts various configuration when passing through your social credentials. Here's an example using Facebook:

use SocialProof\SocialProof;

return SocialProof::social()
  ->facebook()
      ->setUsername('example')
      ->setToken('XXXXXXXXXXXXXXXXXXXXXXXX')
      ->setDefault('No followers')
      ->setApi('https://graph.facebook.com')
      ->setEndpoint('/v2.7/')
      ->setTimeout(60)
      ->setDebug()
  ->get();

A long form syntax is also available for passing credentials and configuration through an array using setCredentials($array) and setConfigs($array) or a string using setCredential($key, $value) and setConfig($key, value).

use SocialProof\SocialProof;

return SocialProof::social()
  ->facebook()
      ->setCredentials([
        'username' => 'example',
        'token' => 'XXXXXXXXXXXXXXXXXXXXXXXX'
      ])
      ->setConfig('default', 'No Followers')
  ->get();

Debugging

Since SocialProof catches API errors, timeouts, etc. and returns a default value instead, you can use ->setDebug() to enable debugging during initial setup.

socialproof's People

Contributors

log1x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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