Social Media Logotype Background

How to retreive shares count from WordPress posts

This script will get number of shares of a post url from usual social networks and return the information as JSON.

Social networks

Currently:

  • Facebook’s likes and shares
  • Twitter
  • LinkedIn’s shares
  • Google plus’ shares

Usage

(You are free to put it anywhere you want if you know how to access it by url, of course.)

  • Drop the file getShares.php in your wordpress main directory, next to wp-config.php file.
  • Call the file by url, per example: http://yoursite.com/getShares.php

Parameters

By default, the script return the last seven days posts, sorted by date of publication (by wordpress) and displayed in a table.
You can override this with parameters:

example: http://yoursite.com/getShares.php?days=1&sort=most&view=json

The script will return posts from the last day, sorted by shares count and in JSON format.

The link

https://gist.github.com/Cog-g/8284663

Todo

  • Add a parameter to get result for only one specific url.

Published by

Constantin Guay

Currently Data Project Manager and Scrum Evangelist at NetMediaEurope, european leader in IT B2B news site (more than 12 million unique visitors per month). Passionate by user experience and data science. Scrum evangelist