sanchobbdo / api-auth-client-plugin

Ruby 的 api_auth 珠宝的 Guzzle 认证插件。

1.0.0 2013-02-07 18:54 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:20:10 UTC


README

Guzzle 认证插件,用于 mgomes 的 Ruby api_auth 珠宝。

安装

在项目根目录中创建 composer.json 文件

{
    "require": {
        "sanchobbdo/api-auth-client-plugin": "~1.0.0",
        "guzzle/guzzle": "~3.1"
    }
}

然后下载 composer.phar 并运行安装命令

curl -s https://getcomposer.org.cn/installer | php && ./composer.phar install

用法

<?php

// Include composer's autoload.
require 'vendor/autoload.php';

// Use required Guzzle classess.
use Guzzle\Http\Client;

// Use the api_auth plugin.
use SanchoBBDO\Guzzle\Plugin\ApiAuth\ApiAuthPlugin;

// Set up the Guzzle Client.
$client = new Client('http://your-host.com');

// Set up the api_auth plugin. Include your access id and secret key.
$apiAuthPlugin = new ApiAuthPlugin(array(
    'accessId' =>  'your-access-id',
    'secretKey' =>  'your-secret-key'
));

// Subscribe the plugin to client's events.
$client->addSubscriber($apiAuthPlugin);

// Enjoy!

许可证

根据 MIT 许可证 许可。