定制 fox-hound-ltd/mixture-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fox-hound-ltd/mixture-api-client

最新稳定版本:0.1.0

Composer 安装命令:

composer require fox-hound-ltd/mixture-api-client

包简介

GraphQL & REST API Client

README 文档

README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

概要

GraphQLとRESTに対応したClientライブラリ

PHP Client for GraphQL & REST

GuzzleHttp Baseベース

インストール

Composerを利用

$ composer require fox-hound-ltd/mixture-api-client

利用方法サンプル

シンプルパターン

<?php
use MixtureApiClient\ClientBuilder;

$client = ClientBuilder::build(
    'https://hogehoge.com/graphql'
);

$query = <<<'QUERY'
query foo(id: 11){
 id
 name
}
QUERY;

$response = $client->query($query);

JsonWebTokenを利用する場合

<?php
use MixtureApiClient\ClientBuilder;
use MixtureApiClient\JWT;

$jwt= new JWT();

$payload['secret_key'] = 'fiwivkbbeec1e958a6c5dd31336242607c0887754b1d43ebf071fb2890533d611a';

$headers = [
    'Authorization' => $jwt->makeToken('secret', $payload),
];

$config = ['headers' => $headers];

$client = ClientBuilder::build(
    'https://hogehoge.com/graphql',
    $config
);

$query = <<<'QUERY'
query GetHoge($target_id: ID, $member_name: String) {
  foo(id: $target_id) {
    id_foo
    bar (name: $member_name) {
      id_bar
    }
  }
}
QUERY;

$variables = [
    'target_id' => 11,
    'member_name' => 'bar',
];
$response = $client->query($query, $variables);

テストについて

$ composer test

ライセンス

The Apache 2.0 license. Please see LICENSE for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-11-08