guysolamour / laravel-hootsuite
A package to interact with social networks via hootsuite api
Requires
- php: >=7.3
- illuminate/support: ^7.0|^8.0|^9.0|^10.0
- shivella/laravel-bitly: ^1.1
- spatie/laravel-settings: ^2.0
Requires (Dev)
- orchestra/testbench: ^4.0|^5.0|^6.0
- phpunit/phpunit: ^8.4|^9.0
README
Installation
Install via composer
composer require guysolamour/laravel-hootsuite
Publish spatie service provider laravel settings package
In case you are already using this package in your project, you can skip this step
php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider"
Add the configuration to the config/settings file generated previously
'settings' => [ ... Guysolamour\Hootsuite\Settings\HootsuiteSettings::class, ]
Add these keys to your .env file
/* Available in your hootsuite dashboard */ HOOTSUITE_CLIENT_ID=your_hootsuite_client_id /* Available in your hootsuite dashboard */ HOOTSUITE_CLIENT_SECRET=your_hootsuite_client_secret /* Only the url path A route will be create with this url path The redirect uri domain must be your website domain */ HOOTSUITE_REDIRECT_URI=your_hootsuite_redirect_uri
Publish package assets
php artisan vendor:publish --provider="Guysolamour\Hootsuite\ServiceProvider"
Run migrations
php artisan migrate
If you wanted to shorten the urls used in your posts. You should get an api key from bitly and add it to your .env file
Publish Laravel Bitly package config file
php artisan vendor:publish --provider="Shivella\Bitly\BitlyServiceProvider"
and add this in your .env file
BITLY_ACCESS_TOKEN=your_bitly_secret_access_token
Then pass this option (s) to true
'bitly_text_link' => true, // for the publication main link 'bity_all_links' => true, // for all links in publication text
Usage
This package allows you to interact with the hootsuite API from a Laravel application. To do this, you must have a hootsuite account and allow the package to access this account.
You can get authorization link with this artisan command
php artisan hootsuite:oauth:url
Make a publication
use Guysolamour\Hootsuite\Facades\Hootsuite; Hootsuite::publish([ 'text' => "This is a text", // required 'hashtags' => ["this, is, a, hashtag"], // or "this|is|a|hashtag" or ['this', 'is', 'a', 'hashtag'] or "this,is,a,hashtag" 'networks' => "Facebook, Twitter, Linkedin", // required 'media' => 'https://domain.com/imagelink.jpg', // ['mediaUrl1', 'mediaUrl2'] 'link' => 'https://link.com', ]);
Schedule a publication
use Guysolamour\Hootsuite\Facades\Hootsuite; Hootsuite::schedule([ 'text' => "This is a text", // required 'hashtags' => ["this, is, a, hashtag"], // or "this|is|a|hashtag" or ['this', 'is', 'a', 'hashtag'] or "this,is,a,hashtag" 'networks' => "Facebook, Twitter, Linkedin", 'media' => 'https://domain.com/imagelink.jpg', // ['mediaUrl1', 'mediaUrl2'] 'link' => 'https://link.com', 'schedule_at' => '2021-01-15 08:59:12' // or carbon instance | required when schedule ]);
Delete a scheduled post that is not yet published
use Guysolamour\Hootsuite\Facades\Hootsuite; Hotsuite::destroy(int $messageId) :bool;
Retrieve information about your account
use Guysolamour\Hootsuite\Facades\Hootsuite; Hootsuite::user();
Check if the post is pending
use Guysolamour\Hootsuite\Facades\Hootsuite; Hootsuite::messageIsStillScheduled(int $messageId);
Get scheduled post
use Guysolamour\Hootsuite\Facades\Hootsuite; Hootsuite::getMessage(int $messageId);
You can type the API directly with these different methods
use Guysolamour\Hootsuite\Facades\Hootsuite; // Get Hootsuite::get(string $url); // Post Hootsuite::post(string $url); // Put Hootsuite::put(string $url); // Delete Hootsuite::delete(string $url);
Security
If you discover any security related issues, please email rolandassale@gmail.com instead of using the issue tracker.
Credits
This package is bootstrapped with the help of melihovv/laravel-package-generator.