sooluh/papercups

非官方的 Papercups PHP 库,从使用服务器端 PHP 编写的应用程序中方便地访问 Papercups API

dev-main 2023-05-24 06:24 UTC

This package is auto-updated.

Last update: 2024-09-24 08:58:01 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

非官方 Papercups PHP 库,从使用服务器端 PHP 编写的应用程序中方便地访问 Papercups API。

要求

  • PHP >= 7.3
  • Composer

特性

  • PSR-4 自动加载兼容的结构
  • PSR-2 兼容的代码风格
  • 易于与任何框架或纯 PHP 文件一起使用
  • 包含有用的工具以优化代码

安装

使用以下命令安装包

composer require sooluh/papercups

用法

该包需要配置一个 API 密钥,该密钥可在 Papercups 控制台 中找到。使用密钥值要求包

<?php
// make sure composer dependencies have been installed
require __DIR__ . '/vendor/autoload.php';

$papercups = new \Papercups\Client('PAPERCUPS_API_KEY');

$response = $papercups->messages()->create([
    'body' => 'Hello world!',
    'conversation_id' => '...'
]);

print_r($response);

如果您在另一台服务器上自行托管 Papercups,可以指定 API 主机

$papercups = new \Papercups\Client('PAPERCUPS_API_KEY', 'https://papercups.mycompany.co');

许可

代码在 MIT 许可证 下授权。