承接 openpublicmedia/roisolutions-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

openpublicmedia/roisolutions-php

最新稳定版本:0.9.1

Composer 安装命令:

composer require openpublicmedia/roisolutions-php

包简介

PHP client for ROI Solutions APIs.

README 文档

README

This library abstracts interactions with ROI Solutions APIs.

Implemented APIs:

Installation

Install via composer:

composer require openpublicmedia/roisolutions-php

Use

REST API

The OpenPublicMedia\RoiSolutions\Rest\Client queries the REST API.

Examples

Creating a client

use OpenPublicMedia\RoiSolutions\Rest\Client;

$userId = 'USER_ID';
$password = 'pAsSw0rD';
$clientCode = 'CLIENTCODE';

$client = new Client($userId, $password, $clientCode);

Providing a cache service is also supported (and recommended) when creating the client. If the client has a cache service it will be used to cache the authentication token provided by the API across multiple requests for the lifetime of the token.

A PSR-16 compliant interface is preferred but any class providing set($key, $value) and get($key, $default) methods will suffice.

use OpenPublicMedia\RoiSolutions\Rest\Client;
use Tochka\Cache\ArrayFileCache;

$userId = 'USER_ID';
$password = 'pAsSw0rD';
$clientCode = 'CLIENTCODE';
$cache = new ArrayFileCache('.', 'my_awesome_cache');

$client = new Client($userId, $password, $clientCode, cache: $cache);

Handling exceptions

Custom exceptions are provided for 404 response and general errors. Additional information from the API response is captured in these exceptions.

use OpenPublicMedia\RoiSolutions\Rest\Exception\RequestException;

try {
    $results = $client->request('get', 'donors');
} catch (RequestException $e) {
    var_dump(get_class($e));
    var_dump($e->getMessage());
    var_dump($e->getCode());
    var_dump($e->getStatusCodeReported());
    var_dump($e->getTitle());
    var_dump($e->getDetail());
    var_dump($e->getInstanceCode());
    var_dump($e->getHelpLink());
}

Development goals

See CONTRIBUTING for information about contributing to this project.

v1

统计信息

  • 总下载量: 271
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2023-08-18