guysolamour/laravel-hootsuite

A package to interact with social networks via hootsuite api

v1.4 2021-02-15 11:09 UTC

This package is auto-updated.

Last update: 2022-01-15 13:13:31 UTC


README

Packagist Packagist Packagist

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,
]

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 its 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.