guysolamour/laravel-hootsuite

一个通过hootsuite api与社交媒体互动的包

v2.3 2023-06-13 18:05 UTC

This package is auto-updated.

Last update: 2024-09-13 21:08:10 UTC


README

Packagist Packagist Packagist

安装

通过composer安装

composer require guysolamour/laravel-hootsuite

发布spatie服务提供程序 laravel settings

如果你已经在你的项目中使用了这个包,你可以跳过这一步

php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider"

将配置添加到先前生成的 config/settings 文件中

'settings' => [
  ...
  Guysolamour\Hootsuite\Settings\HootsuiteSettings::class,
]

将这些键添加到你的 .env 文件中

/*
  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

发布包资源

php artisan vendor:publish --provider="Guysolamour\Hootsuite\ServiceProvider"

运行迁移

php artisan migrate

如果你想要缩短你帖子中使用的网址,你应该从 bitly 获取一个API密钥并将其添加到你的 .env 文件中

发布 Laravel Bitly 包的配置文件

php artisan vendor:publish --provider="Shivella\Bitly\BitlyServiceProvider"

并在你的 .env 文件中添加以下内容

BITLY_ACCESS_TOKEN=your_bitly_secret_access_token

然后传递这个选项(s)为true

'bitly_text_link' => true, // for the publication main link
'bity_all_links'  => true, // for all links in publication text

用法

此包允许您从Laravel应用程序中与hootsuite API交互。为此,您必须有一个hootsuite账户,并允许此包访问此账户。

您可以使用以下artisan命令获取授权链接

php artisan hootsuite:oauth:url

发布内容

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',
]);

安排发布

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
]);

删除尚未发布的计划帖子

use Guysolamour\Hootsuite\Facades\Hootsuite;


Hotsuite::destroy(int $messageId) :bool;

检索您的账户信息

use Guysolamour\Hootsuite\Facades\Hootsuite;

Hootsuite::user();

检查帖子是否待处理

use Guysolamour\Hootsuite\Facades\Hootsuite;

Hootsuite::messageIsStillScheduled(int $messageId);

获取计划帖子

use Guysolamour\Hootsuite\Facades\Hootsuite;

Hootsuite::getMessage(int $messageId);

您可以直接使用这些不同的方法使用API

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);

安全

如果您发现任何安全相关的问题,请通过电子邮件 rolandassale@gmail.com 而不是使用问题跟踪器。

致谢

此包是在melihovv/laravel-package-generator的帮助下启动的。