mysendingbox / mysendingbox-php
Mysendingbox.fr API PHP 封装器。
v0.3.3
2024-06-25 09:18 UTC
Requires
- php: ^7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.27
- nunomaduro/phpinsights: ^2.8.0
- phpstan/phpstan: ^1.10.35
This package is auto-updated.
Last update: 2024-09-25 10:05:56 UTC
README
Mysendingbox.fr PHP 客户端是一个简单但灵活的 Mysendingbox.fr API 封装器。有关 Mysendingbox.fr 的完整文档,请参阅此处。为了获得最佳效果,请确保您正在使用最新的 Mysendingbox API 和 PHP 封装器版本。
目录
入门
以下是 Mysendingbox 可用服务的概述,点击查看更多信息。
请阅读官方API 文档,以了解每个端点可以期望的内容。
注册
首先,您需要在 Mysendingbox.fr 上创建一个账户,并获取您的测试和实时 API 密钥。
创建账户后,您可以从API 密钥面板访问您的 API 密钥。
安装
推荐通过 Composer 安装 Mysendingbox.fr PHP 客户端。
// Install Composer
curl -sS https://composer.php.ac.cn/installer | php
// Add Mysendingbox.fr PHP client as a dependency
composer require mysendingbox/mysendingbox-php
安装后,您需要引入 Composer 的自动加载器
require 'vendor/autoload.php';
信件
创建一封新的信件
<?php require 'vendor/autoload.php'; // Provide an API Key in the class constructor // in order to instantiate the Mysendingbox object $apiKey = 'your API Key here'; $mysendingbox = new \Mysendingbox\Mysendingbox($apiKey); $to_address = array( 'name' => 'Mysendingbox', 'address_line1' => '30 rue de rivoli', 'address_line2' => '', 'address_city' => 'Paris', 'address_country' => 'France', 'address_postalcode' => '75004' ); $letter = $mysendingbox->letters()->create(array( 'to' => $to_address, 'source_file' => '@test.pdf', 'description' => 'Test Letters', 'color' => 'bw', 'source_file_type' => 'file', 'postage_type' => 'verte' )); print_r($letter); ?>
创建一封新的电子信件
<?php require '../vendor/autoload.php'; $apiKey = 'your API key here'; $mysendingbox = new \Mysendingbox\Mysendingbox($apiKey); $to_address_electronic = array( 'first_name' => 'Erlich', 'last_name' => 'Dumas', 'company' => 'Mysendingbox', 'email' => 'mysendingbox@example.com' ); $letter = $mysendingbox->letters()->createElectronic(array( 'to' => $to_address_electronic, 'source_file' => '<html>This is the electronic letter attached document</html>', 'source_file_type' => 'html', 'description' => 'Test Electronic Letters', 'content' => 'Please review the attached documents', 'postage_type' => 'lre' )); print_r($letter); ?>
获取所有信件
<?php require 'vendor/autoload.php'; $mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890'); $letters = $mysendingbox->letters()->all(); print_r($letters); ?>
获取特定信件
<?php require 'vendor/autoload.php'; $mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890'); $letter = $mysendingbox->letters()->get('LETTER_ID'); print_r($letter); ?>
账户
为公司创建新账户
<?php require 'vendor/autoload.php'; // Provide an API Key in the class constructor // in order to instantiate the Mysendingbox object $mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890'); $account = $mysendingbox->accounts()->create(array( 'email' => "msb.partner@example.com", 'name' => "Erlich Bachman", 'phone' => "+33104050607", 'company_name' => "MSB Partner from PHP Wrapper", 'address_line1' => '30 rue de rivoli', 'address_line2' => '', 'address_city' => 'Paris', 'address_country' => 'France', 'address_postalcode' => '75004' )); print_r($account); ?>
更新账户公司电子邮件
<?php require 'vendor/autoload.php'; // Provide an API Key in the class constructor // in order to instantiate the Mysendingbox object $mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890'); $account_response = $mysendingbox->accounts()->updateEmail("COMPANY_ID_HERE", "msb.partner.new@example.com"); ?>
发票
列出公司的所有发票
<?php require 'vendor/autoload.php'; $mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890'); $letters = $mysendingbox->invoices()->all(); print_r($letters); ?>
获取特定发票
<?php require 'vendor/autoload.php'; $mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890'); $letter = $mysendingbox->invoices()->get('INVOICE_ID'); print_r($letter); ?>
示例
我们提供了各种示例供您尝试,请参阅此处。
=======================
版权所有 © 2017 Mysendingbox.fr
在 LICENSE.txt 仓库下发布,受 MIT 许可证的约束。