ruwer / toparticles
There is no license information available for the latest version (dev-master) of this package.
Get the top read articles of your page.
dev-master
2016-07-08 13:58 UTC
Requires
- google/apiclient: ^2.0
This package is not auto-updated.
Last update: 2026-03-01 03:37:25 UTC
README
- A Laravel 5 package used to list your top articles by date.
- Uses Google Analytics API.
First of all
1.
- Go to: https://console.developers.google.com/apis/credentials
- Create credentials
- Service account key
- New service account
- Put the name, select JSON and Create!
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 :)