hafael / php-http-client
PHP HTTP RESTful API 客户端。
v0.1.0
2023-01-25 20:35 UTC
Requires
- php: >=7.3
- guzzlehttp/guzzle: >=6.0
Requires (Dev)
- phpunit/phpunit: 5.5.*
README
PHP HTTP 客户端用于PHP
此库为开发者提供了一组简单的绑定,帮助您将REST API集成到PHP项目中。
💡 要求
PHP 7.3或更高版本
📦 安装
-
如果尚未安装,请下载Composer
-
在您的项目目录中,通过命令行运行
composer require "hafael/php-http-client"
-
扩展您需要的类。
PHP HTTP 客户端已成功安装。
🌟 入门指南
简单用法如下
<?php require_once 'vendor/autoload.php'; // You have to require the library from your Composer vendor folder use Hafael\HttpClient\Client; class MyCustomClient extends Client { /** * The Client (not Eastwood) * * @param string $apiKey * @param string $baseUrl */ public function __construct(string $apiKey, string $baseUrl) { $this->setApiKey($apiKey); $this->setBaseUrl($baseUrl); } } $customClient = new MyCustomClient( 'API_KEY', 'https://myapiendpoint.com.br', ); //Get Api Method $response = $customClient->exampleOfApiResource() ->getExampleResourceMethod(); var_dump($response->json()); ?>
创建新的KYC账户
<?php require_once 'vendor/autoload.php'; use Hafael\Fitbank\Client; use Hafael\Fitbank\Models\Account; use Hafael\Fitbank\Models\Address; use Hafael\Fitbank\Models\Document; use Hafael\Fitbank\Models\Person; ... //Create new KYC Account $holder = new Person([ 'personRoleType' => Person::ROLE_TYPE_HOLDER, 'taxNumber' => '88494940090', 'identityDocument' => '269435310', 'personName' => 'Rafael da Cruz Santos', 'nickname' => 'Rafael', 'mail' => 'rafaelmail@meuemail.com', 'phoneNumber' => '219729345534', 'checkPendingTransfers' => false, 'publicExposedPerson' => false, 'birthDate' => '1991/03/20', 'motherFullName' => 'Daniela Cruz de Marquez', 'fatherFullName' => 'João Francisco Santos', 'nationality' => 'Brasileiro', 'birthCity' => 'Niterói', 'birthState' => 'Rio de Janeiro', 'gender' => Person::GENDER_MALE, 'maritalStatus' => Person::MARITAL_SINGLE, 'occupation' => 'Empresário', ]); $documents = [ Document::fromBase64('dGVzdGU=', Document::FORMAT_JPG) ->documentType(Document::TYPE_CNH) ->expirationDate('2023/04/15'), Document::fromBase64('dGVzdGU=', Document::FORMAT_JPG) ->documentType(Document::TYPE_PROOF_ADDRESS), ]; $addresses = [ new Address([ 'addressType' => Address::RESIDENTIAL, 'addressLine' => 'Av. Quintino de Bocaiúva', 'addressLine2' => '61', 'complement' => 'McDonald`s', 'zipCode' => '24360-022', 'neighborhood' => 'São Francisco', 'cityName' => 'Niterói', 'state' => 'RJ', 'country' => 'Brasil', ]) ]; $account = new Account([ 'holder' => $holder, 'documents' => $documents, 'addresses' => $addresses, ]); $response = $fitbankClient->account->newAccount($account); var_dump($response->json()); ?>
📚 文档
访问我们的开发者网站以获取更多关于以下内容的信息
- Fitbank API 文档:英文