This package provides integration with the MainWP API. It currently only supports sending a chat message.
You can install this package via Composer using:
composer require kylewlawrence/laravel-mainwp-apiThe facade is automatically installed.
MainWP::get('sites', ['per_page' => 100]);To publish the config file to app/config/mainwp-laravel.php run:
php artisan vendor:publish --provider="KyleWLawrence\MainWP\Providers\MainWPServiceProvider"Set your configuration using environment variables, either in your .env file or on your server's control panel:
MAINWP_DOMAIN
The fully qualified domain name where MainWP is hosted.
MAINWP_BEARER_TOKEN
If you are using the V2 API, you will need to set the bearer token for authentication. You can create one as described here: https://kb.mainwp.com/docs/mainwp-rest-api/
MAINWP_API_VERSION(Optional)
The version of the MainWP API to use. Defaults to v2. If you are using the V1 API, set this to v1.
MAINWP_CONSUMER_KEY
If you are using the v1 API, these are the two credentials you will need to complete. You can create them as described here: https://kb.mainwp.com/docs/mainwp-rest-api/
MAINWP_CONSUMER_SECRET
Accompanying the consumer key.
MAINWP_DRIVER(Optional)
Set this to null or log to prevent calling the MainWP API directly from your environment.
Pull Requests are always welcome here. I'll catch-up and develop the contribution guidelines soon. For the meantime, just open and issue or create a pull request.
The MainWP facade acts as a wrapper for an instance of the MainWP\Http\HttpClient class.
If you'd prefer not to use the facade, you can instead inject KyleWLawrence\MainWP\Services\MainWPService into your class. You can then use all of the same methods on this object as you would on the facade.
<?php
use KyleWLawrence\MainWP\Services\MainWPService;
class MyClass {
public function __construct(MainWPService $mainwp_service) {
$this->mainwp_service = $mainwp_service;
}
public function getSites() {
$this->mainwp_service->get('sites/all-sites');
}
}This package is available under the MIT license.