承接 perinatologie/hub-client-php 相关项目开发

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

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

perinatologie/hub-client-php

最新稳定版本:v2.0.0

Composer 安装命令:

composer require perinatologie/hub-client-php

包简介

README 文档

README

Getting started

Install dependencies:

Get PHP dependencies using Composer

composer install

Examples

Setup environment variables

Before running the examples, make sure the following environment variables have been configured:

export HUB_URL="http://127.0.0.1:8080"
export HUB_V1_USERNAME=joe
export HUB_V1_PASSWORD=secret
export HUB_V3_USERNAME=joe
export HUB_V3_PASSWORD=secret

Hub v1 and v3 use different authentication methods, therefor you can specify them separately.

Note, the v1 credentials are also used to access resources at providers for v1 security hashes.

You can use a .env file, by copying the .env.dist to .env and updating it with your credentials.

Run the examples

php examples/v1/getdossierinfo.php {bsn}
php examples/v3/search.php client_bsn=987654321

Build the v4 API client

The v4 API Client authenticates itself with the Hub using a Json Web Token (JWT) which it obtains from UserBase. The username and password you usually use to authenticate with the Hub are used to authenticate with UserBase and obtain a JWT. Thereafter, the v4 client is used in the same way as the v3 client.

use Hub\Client\Exception\ClientCreationException;
use Hub\Client\Exception\ResponseException;
use Hub\Client\Factory\ApiClientFactory;

require_once '/path/to/vendor/autoload.php';

$userbaseUrl = 'http://userbase.example.com/auth';
$hubUrl = 'http://hub.example.com';
$username = 'my-username';
$password = 'my-password';

$clientFactory = new ApiClientFactory($hubUrl);
$clientFactory->setUserbaseJwtAuthenticatorUrl($userbaseUrl);
try {
    $client = $clientFactory->createV4Client($username, $password);
} catch (ClientCreationException $e) {
    // failed to create the client: probably failed to obtain a JWT
    echo $e->getMessage() . PHP_EOL;
    exit();
}
try {
    $resources = $client->findResources();
} catch (ResponseException $e) {
    echo $e->getMessage() . PHP_EOL;
    exit();
}
var_dump($resources);

cacert.pem

For Guzzle versions > 4, curl is used to verify remote SSL connections. In order for this to work, you'll need to pass a verify key to guzzle, pointing to a .pem file containing all trusted CA's.

These are published by curl here:

If needed, you can download new ca certificates from there, and put them in the root of this project.

License

MIT. Please refer to the included LICENSE.md file

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-20