nocake/msggo
最新稳定版本:v1.0.0
Composer 安装命令:
composer require nocake/msggo
包简介
PHP SDK for interacting with the MsgGO API.
README 文档
README
This is the official PHP SDK for interacting with the MsgGO API. It allows you to easily send events to your MsgGO inbox from your PHP applications.
The SDK is compliant with PSR standards.
Requirements
- PHP 8.0 or higher
- cURL extension
- JSON extension
Installation
You can install the SDK via Composer. Run the following command in your project directory:
composer require nocake/msggo
Usage
First, you need to obtain an API key from your MsgGO dashboard.
<?php require_once __DIR__ . '/vendor/autoload.php'; use NoCake\MsgGo\Client; use NoCake\MsgGo\Client\Exception\ApiException; // Replace 'YOUR_MSGGO_API_KEY' with your actual API key $apiKey = 'YOUR_MSGGO_API_KEY'; try { // Basic instantiation $client = new Client($apiKey); // Optionally, override the base API URL // $clientWithCustomUrl = new Client($apiKey, ['api_base_url' => 'https://custom.msggo.instance.com']); $eventData = [ 'event' => 'my-event', 'username' => 'john_doe', 'email' => 'john.doe@example.com', 'source' => 'website_signup_form' ]; // Send an event $client->event($eventData); } catch (\InvalidArgumentException $e) { // Handle errors related to invalid arguments (e.g., empty API key) echo "Argument Error: " . $e->getMessage() . "\n"; } catch (ApiException $e) { // Handle API-specific errors (e.g., authentication failure, validation error) echo "API Error: " . $e->getMessage() . "\n"; echo "Error: " . $e->getError() . "\n"; } catch (\RuntimeException $e) { // Handle other runtime errors (e.g., cURL issues, JSON decoding errors not from API) echo "Runtime Error: " . $e->getMessage() . "\n"; } ?>
API Documentation
For more details on the MsgGO API and its capabilities, please refer to the official MsgGO documentation.
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue.
License
The MsgGO PHP SDK is licensed under the MIT License. See the LICENSE file for more details.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-06