2017 © Pedro Peláez
 

library smart_request

http request with curl

image

forfire/smart_request

http request with curl

  • Friday, May 4, 2018
  • by nodephp
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 50 % Grown

The README.md

smartRequest use php-curl

install

composer require forfire/smart_request, (*1)

use

use Smart\SmartRequest;
$params = ['q' => 'golang', 'start' => 0, 'count' => 1];
$res = SmartRequest::request('get', 'https://api.douban.com/v2/book/search',$params , [], [], true);

desc

SmartRequest::request($method,$url,$params,$headers,$options,$needJosn)
field type desc example
method string request type get/post
url string request url https://api.douban.com/v2/book/search
params array request params ['q' => 'golang', 'start' => 0, 'count' => 1]
headers array request header ['Content-Type: application/json']
options array curl options [CURLOPT_HEADER => 1,CURLOPT_RETURNTRANSFER => 1]
needJson bool need json parse default true

explames

POST with header

$params = ['fql' => ['tp' => 'note', 'con' => ['keywords' => '吃'], 'page' => ['start' => 0, 'num' => 1]]];
$headers = ['Content-Type: application/json'];
$res = SmartRequest::request('post', 'https://api.douban.com/v2/book/search', $params, $headers, [], true);

add options

$params = ['fql' => ['tp' => 'note', 'con' => ['keywords' => '吃'], 'page' => ['start' => 0, 'num' => 1]]];
$options = [CURLOPT_HEADER => 1,CURLOPT_RETURNTRANSFER => 1];
$res = SmartRequest::request('post', 'https://api.douban.com/v2/book/search', $params, [], $options, true);

The Versions

04/05 2018

dev-master

9999999-dev

http request with curl

  Sources   Download

by forfire

04/05 2018

v0.02

0.02.0.0

http request with curl

  Sources   Download

by forfire

12/04 2018

0.0.1

0.0.1.0

http request with curl

  Sources   Download

by forfire