ruwer / toparticles
Get the top read articles of your page.
Installs: 5 828
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- google/apiclient: ^2.0
This package is not auto-updated.
Last update: 2024-11-09 19:34:16 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 :)