yproximite/yprox-api-client-bundle

为 Symfony 集成 yProx API 客户端库

v3.0.0 2020-11-03 12:05 UTC

This package is auto-updated.

Last update: 2024-08-29 04:40:19 UTC


README

安装

yproximite/yprox-api-client-bundle 添加到您的 composer.json 文件中

$ composer require yproximite/yprox-api-client-bundle

app/AppKernel.php 中注册此包

// app/AppKernel.php
public function registerBundles()
{
    return [
        // ...
        new Yproximite\Bundle\YproxApiClientBundle\YproxApiClientBundle(),
    ];
}

配置

以下为配置参考

# app/config/config.yml
yprox_api_client:

    # Identifier of the service that represents "Http\Client\HttpClient"
    http_client: httplug.client.guzzle6

    clients:

        # Simple example
        default:
            api_key: xxxxx

        # Advanced example
        custom:
            api_key: yyyyy
            base_url: http://api.host.com

使用方法

// yprox_api_client.service_aggregator.<client_name_from_config>
$api = $this->get('yprox_api_client.service_aggregator.default');

$message = new ArticleListMessage();
$message->setSiteId(1);

// Yproximite\Api\Model\Article\Article[]
$articles = $api->article()->getArticles($message);