2

古いバージョンの Guzzle でかなり長い間使用していた次のサービスの説明があります。

[
    'name'        => 'Gist',
    'apiVersion'  => 'v3',
    'baseUrl'     => 'https://api.github.com/',
    'description' => 'Gists and comments access',
    'operations'  => [
        'GetGists'    => [
            'httpMethod' => 'GET',
            'uri'        => '/users/{user}/gists',
            'parameters' => [
                'user'  => [
                    'location' => 'uri',
                    'required' => true,
                ],
                'since' => [
                    'location' => 'query',
                ],
            ],
        ],
        'GetComments' => [
            'httpMethod' => 'GET',
            'uri'        => '/gists/{id}/comments',
            'parameters' => [
                'id' => [
                    'location' => 'uri',
                    'required' => true,
                ],
            ],
        ],
    ],
]

今、私はたくさんのものをGuzzleの現在のバージョンに移していますが、これは新しいブレイクアウトで動作することを絶対に拒否していguzzle/servicesます.

私のコードは次の行に沿っています:

$client = new Client;
$client->setDefaultOption('verify', false);
$description  = new Description($this->getServiceDescription());
$guzzleClient = new GuzzleClient($client, $description);
$command      = $guzzleClient->getCommand('GetGists', [ 'user' => $this->user ]);
$gists        = $guzzleClient->execute($command); // $gists is empty array?..

必要な引数やスペルミスのある名前を指定しないと文句を言うので、少なくとも部分的にコマンドを明確に理解しています。

しかし、最終的には空の配列であり、トラブルシューティングを行うために何をする必要があるか、またはサービスの説明をどのように更新する必要があるかはわかりません。

アクセスする必要がある (アクセスする?) URL はhttps://api.github.com/users/Rarst/gistsです。

4

1 に答える 1

2

わかりました、モデルは応答を解釈するために必須のようで、私はそれを機能させました(モデルが何をどのように制御するかについてあまり理解していません:\):

[
    'name'        => 'Gist',
    'apiVersion'  => 'v3',
    'baseUrl'     => 'https://api.github.com/',
    'description' => 'Gists and comments access',
    'operations'  => [
        'GetGists'    => [
            'responseModel' => 'getResponse',
            'httpMethod'    => 'GET',
            'uri'           => '/users/{user}/gists',
            'parameters'    => [
                'user'  => [
                    'location' => 'uri',
                    'required' => true,
                ],
                'since' => [
                    'location' => 'query',
                ],
            ],
        ],
        'GetComments' => [
            'responseModel' => 'getResponse',
            'httpMethod'    => 'GET',
            'uri'           => '/gists/{id}/comments',
            'parameters'    => [
                'id' => [
                    'location' => 'uri',
                    'required' => true,
                ],
            ],
        ],
    ],
    'models'      => [
        'getResponse' => [
            'type'                 => 'object',
            'additionalProperties' => [
                'location' => 'json'
            ]
        ]
    ]
]
于 2014-12-11T22:48:22.120 に答える