2017 © Pedro Peláez
 

library http

http client

image

zodream/http

http client

  • Sunday, July 29, 2018
  • by zx648383079
  • Repository
  • 1 Watchers
  • 0 Stars
  • 62 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 15 % Grown

The README.md

http

优雅链式调用API, (*1)

示例

引用, (*2)


use Zodream\Http\Http;

获取指定网址内容, (*3)


(new Http('https://zodream.cn'))->get();

传递GET 参数, (*4)


(new Http())->url('https://zodream.cn', [ 'page' => 1 ])->get();

传递 POST, (*5)


(new Http('https://zodream.cn'))->maps([ 'page' => 1 ])->text();

高级用法

自动进行值的填充, (*6)


(new Http())->url('https://zodream.cn', [ 'keywords' ])->maps([ 'page' => 1, // 这是使用默认值 '#url' // 如果没有会报错 ])->parameters([ 'url' => 'aaaa', 'keywords' => 'q', 'aa' => 'bb' // 这个并不会传递过去 ])->encode(Http::JSON)->decode(Http::Json)->decode(function($data) { $data['a'] = $data['data']; return $data; })->text();

相当于, (*7)

请求 https://zodream.cn/?keywords=q, (*8)

POST {"page":1, "url":"aaaa"}, (*9)

获取的结果是 {"code":200, "data":"a"}, (*10)

最后你接收到的是数组, (*11)


[ 'code' => 200, 'data' => 'a', 'a' => 'a' ]

值自动匹配


$data = Http::getMapParameters([ '#goods_id', // # 必须有值 否则报错 'a:f' => [ // 如果 f 有值 传给 a 即 a => 2,如果无值, 进行子匹配 a => [e => 11] '#e' ], [ // 多个里面匹配至少一个 'b', 'c', 'd' ], 'g' => 1 // 可以设置默认值, 数组不是默认值 ], [ 'goods_id' => 1, 'f' => 2, 'c' => 4, 'd' => 7, 'e' => 11 ]);

The Versions

29/07 2018

dev-master

9999999-dev https://github.com/zodream/http

http client

  Sources   Download

MIT Apache Licence 2.0

The Requires

 

http client zodream

27/06 2018

2.3

2.3.0.0 https://github.com/zodream/http

http client

  Sources   Download

MIT

The Requires

 

http client zodream

28/04 2018

2.2

2.2.0.0 https://github.com/zodream/http

http client

  Sources   Download

MIT

The Requires

 

http client zodream

27/02 2018

v2.1

2.1.0.0 https://github.com/zodream/http

http client

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

http client zodream

24/01 2018

v2.0

2.0.0.0 https://github.com/zodream/http

http client

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

http client zodream

30/09 2017

v1.0

1.0.0.0 https://github.com/zodream/http

http client

  Sources   Download

Apache Licence 2.0

The Requires

  • php >=5.6.0

 

http client zodream