Php 在实例化客户机时,如何从Guzzle服务描述中访问值?

Php 在实例化客户机时,如何从Guzzle服务描述中访问值?,php,guzzle,guzzle-service-description,Php,Guzzle,Guzzle Service Description,我正在使用服务描述创建Guzzle客户端。服务描述中的每个操作都包含一个URI。我正在访问的REST端点需要一个授权头,该授权头是通过将公钥和端点的uri粘在一起,然后从结果字符串创建md5来实现的。这将用作授权值 我不知道在实例化客户端之后如何从服务描述中获取uri值 我正在创建Guzzle客户端,如下所示: class RestClient extends Client { public static function factory($config = array()) {

我正在使用服务描述创建Guzzle客户端。服务描述中的每个操作都包含一个URI。我正在访问的REST端点需要一个授权头,该授权头是通过将公钥和端点的uri粘在一起,然后从结果字符串创建md5来实现的。这将用作授权值

我不知道在实例化客户端之后如何从服务描述中获取uri值

我正在创建Guzzle客户端,如下所示:

class RestClient extends Client
{
  public static function factory($config = array())
  {

    // The following values are required when creating the client
    $required = array(
      'base_url',
      'public_key',
      'private_key'
    );

    $path = drupal_get_path('module', 'junkrest');

    // Merge in default settings and validate the config
    $config = Collection::fromConfig($config, $required);

    // Create a new client
    $client = new self($config->get('base_url'), $config);
        // Set the service description
    $client->setDescription(ServiceDescription::factory($path . '/config/services.json'));

        $authstring = md5($public_key, 'the uri value from an operation in the services.json file');

    $client->setDefaultHeaders(array(
      'Authentication' => $authstring));

    return $client;
  }

}

The services.json file contains this:

{
    "name": "TheName",
    "apiVersion": "1",
    "baseUrl": "https://apidev.example.com",
    "description": "Custom REST API client",
    "operations": {
        "GetFranchiseList": {
            "httpMethod": "GET",
            "uri": "v1/franchise",
            "summary": "Returns an array of franchises."
        },
        "GetReviews": {
            "httpMethod": "GET",
            "uri": "v1/review",
            "summary": "Returns an array of reviews."
        }
    }
}

如何访问GetList中的“uri”值,以便使用它创建$authstring?

客户端有一个包含操作的服务描述对象。这些操作包含各种属性的getter方法以及用作输入的每个参数

例如:

$client->getDescription()->getOperation('GetFranchiseList')->getUri();