定制 segpacto/yii2-httpfull 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

segpacto/yii2-httpfull

Composer 安装命令:

composer require segpacto/yii2-httpfull

包简介

Extension conversion of 'Httpful' to yii2 extension

README 文档

README

Extension conversion of 'Httpful' to yii2 extension

Installation

The preferred way to install this extension is through composer.

Since it is not published on packages.org needs to be installed manually using composer add to your composer.json

"repositories":[
    {
        "type": "git",
        "url": "https://path.to/your/repo"
    }
]

since the file is local the 'url' should be "url" : "file:///path_to_your_file"

Either run

php composer.phar require --prefer-dist segpacto/yii2-httpfull "*"

or add

"segpacto/yii2-httpfull": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

// Make a request to the GitHub API with a custom
// header of "X-Trvial-Header: Just as a demo".
$url = "https://api.github.com/users/nategood";
$response = \HttpFull\Request::get($url)
    ->expectsJson()
    ->withXTrivialHeader('Just as a demo')
    ->send();

echo "{$response->body->name} joined GitHub on " .
                        date('M jS', strtotime($response->body->created_at)) ."\n";

Ex 1: Send off a GET request. Get automatically parsed JSON response. The library notices the JSON Content-Type in the response and automatically parses the response into a native PHP object.

$uri = "https://www.googleapis.com/freebase/v1/mqlread?query=%7B%22type%22:%22/music/artist%22%2C%22name%22:%22The%20Dead%20Weather%22%2C%22album%22:%5B%5D%7D";
$response = \HttpFull\Request::get($uri)->send();

echo 'The Dead Weather has ' . count($response->body->result->album) . " albums.\n";

Ex 2:

$uri = 'https://example.net/person.xml';
$response = \HttpFull\Request::get($uri)
    ->expectsXml()
    ->send();

echo "Name: $response->body->name";

Note : This is based on the package shared by nategood. This is only a conversion to use as Yii2 extension. For further explanation and documentation of the package go directly their documentation.

统计信息

  • 总下载量: 16.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固