kfosoft/php-restful-client

该包最新版本(1.0)没有提供许可信息。

PHP RESTful Client

1.0 2015-09-25 20:40 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:20:26 UTC


README

安装

使用Composer安装

运行以下命令之一:

    php composer.phar require --prefer-dist kfosoft/rest-client:"*"

或在composer.json中添加以下内容

    "require": {
            ...
            "kfosoft/php-restful-client":"*"
    }

做得好!

示例调用 GET

    $result = (new RestClient())->requestParams(RestClient::GET, $url, $data)->call();

示例调用带有 GET 数据的 CUSTOM

    $result = (new RestClient())->requestParams(RestClient::CUSTOM, $url, $data)->call();

示例调用带有 POST 数据的 CUSTOM

    $result = (new RestClient())->requestParams(RestClient::CUSTOM, $url, $data)->usePost()->call();

示例调用带有 http 认证的 URL

    $result = (new RestClient())->requestParams(RestClient::POST, $url, $data)->useHttpAuth($username, $password)->call();

使用响应内容类型

    $result = (new RestClient())->requestParams(RestClient::PATCH, $url, $data)->useResponseContentType()->call();

在 stdClass 中获取结果

    $result = (new RestClient())->requestParams(RestClient::PUT, $url, $data)->usePost()->call(true);

大家,享受吧!