rfink/edmunds-php-api

edmunds api 套件

v0.0.0 2013-07-07 20:46 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:39:51 UTC


README

Edmunds 车辆API资源集合。使用的HTTP客户端是Guzzle(http://guzzlephp.org)。

使用方法

您首先需要一个API密钥。您可以访问http://developer.edmunds.com并申请开发API密钥。Edmunds API包含4个不同的API,您需要为每个API申请一个密钥。关于这个过程,我不会在这里详细介绍。

在 simplest 的形式中,您可以使用它如下

In your composer.json, add the following dependency (replace {version} with latest version):

    "rfink/edmunds-php-api": "{version}"

Then run composer update from the command line.

Inside your app, you can bootstrap the guzzle client by adding the following code:

    $vehicleClient = \RF\Edmunds\Vehicle\Client::factory(array(
        'api_key' => '{your_api_key_here}',
        'base_url' => 'http://api.edmunds.com'
    ));

Then, you can run commands:

    $args = array('id' => '100533210');
    $command = $client->getCommand('modelYear.findById', $args);
    $response = $command->execute()->toArray();

Response will contain a plain php array representing the API response payload.

要了解这个API如何实际工作,最好的方法是查看单元测试,以及Edmunds开发者网站上的API描述。服务描述JSON文件也是查看每个调用所需参数和响应格式的良好位置。

正在开发一个symfony2包,将其作为一个服务包装,请参阅https://github.com/rfink/EdmundsBundle

**此API仍在高度、高度alpha模式。在生产环境中使用时请自行承担风险。**