PHP code example of forfire / smart_request

1. Go to this page and download the library: Download forfire/smart_request library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

forfire / smart_request example snippets


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

SmartRequest::request($method,$url,$params,$headers,$options,$needJosn)

$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);

$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);