Skip to content

ricardoruwer/TopArticles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

TopArticles for Laravel 5

  • A Laravel 5 package used to list your top articles by date.
  • Uses Google Analytics API.

First of all

1.

2.

  • Open the downloaded file.
  • Copy the e-mail at "client_email".
  • Go to: https://analytics.google.com
  • Admin
  • Select your account and go to User Management
  • Paste the e-mail on the input and Add!
  • Now copy the JSON file to your project.

Instalation

composer require "ruwer/toparticles":"dev-master"

Add to your config/app.php:

'providers' => [
    //...
    Ruwer\TopArticles\TopArticlesServiceProvider::class,
],

and:

'aliases' => [
    //...
    'TopArticles' => Ruwer\TopArticles\TopArticlesFacade::class,
],

In your terminal:

php artisan vendor:publish --provider="Ruwer\TopArticles\TopArticlesServiceProvider"
composer dump-autoload

Now open the file: config/analytics.php and configure the path of your JSON file generated by Google Analytics.

How to use

In your controller:

use TopArticles;

TopArticles::get(
    "ga:xxxxxxxx", //Your Google Analytics Profile ID
    "7daysAgo", //Begin Date
    "today", //End date (you can also use Y-m-d)
    "(articles/)", //Regex for Filters (everything containing "articles/")
    10 //Results
);

//It'll return an array with your top viewed articles :)

About

If you'd like to show, e.g.: the top 10 articles of your website by week

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages