nguyenanhung / requests
我的请求库
v4.0.2
2024-09-21 19:41 UTC
Requires
- php: ^8.0 || ^7.0
- ext-curl: *
- ext-iconv: *
- ext-json: *
- guzzlehttp/guzzle: ^7 || ^6
- nguyenanhung/ip-helper: ^2.0 || ^1.0
- nguyenanhung/my-debug: ^4.0 || ^3.0 || ^2.0
- nguyenanhung/nusoap: ^0.9
- php-curl-class/php-curl-class: ^9 || ^8
- symfony/http-foundation: ^7.0 || ^6.0 || ^5.4 || ^4.4 || ^3.4
- symfony/polyfill-mbstring: >= 1.0
Requires (Dev)
- kint-php/kint: ^5 || ^4 || ^3 || ^2 || ^1
Suggests
- ext-curl: Needed to support cURL
- ext-iconv: Needed to support iconv
- ext-json: Needed to support JSON
- ext-mbstring: Needed to support mb_string
- ext-openssl: Needed to support SSL
- dev-master
- v4.x-dev
- v4.0.2
- v4.0.1
- v4.0.0
- v3.x-dev
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.9
- v3.0.8
- v3.0.7.1
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.x-dev
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.8.2
- v2.0.8.1
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2.1
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0
- v0.1.3.17
- v0.1.3.16
- v0.1.3.15
- v0.1.3.14
- v0.1.3.13
- v0.1.3.12
- v0.1.3.11
- v0.1.3.10
- v0.1.3.9
- v0.1.3.8
- v0.1.3.7
- v0.1.3.6
- v0.1.3.5
- v0.1.3.4
- v0.1.3.3
- v0.1.3.2
- v0.1.3.1
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
This package is auto-updated.
Last update: 2024-09-21 19:42:24 UTC
README
我的请求
库接口请求使用cURL、文件获取内容、SOAP请求
库使用包:Curl、GuzzleHttp和nuSOAP
版本
- V1.x, V2.x支持所有PHP版本
>=5.6
- V3.x支持所有PHP版本
>=7.0
- V4.x支持所有PHP版本
>=8.0
安装
手动安装
步骤 1: 将库保存到您的项目
cd /your/to/path
wget https://github.com/nguyenanhung/requests/archive/master.zip
unzip master.zip
步骤 2: 初始化到项目
<?php require '/your/to/path/MyRequests.php'; use \nguyenanhung\MyRequests\MyRequests; $requests = new MyRequests();
使用composer安装
步骤 1: 安装包
composer require nguyenanhung/requests
步骤 2: 初始化到项目
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\MyRequests\MyRequests; $requests = new MyRequests();
如何使用
获取库版本
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\MyRequests\MyRequests; $requests = new MyRequests(); echo $requests->getVersion(); // Print: 1.0.14
发送请求
<?php require '/your/to/path/vendor/autoload.php'; use nguyenanhung\MyRequests\MyRequests; $debug = [ 'debugStatus' => TRUE, 'debugLoggerPath' => testLogPath() ]; $url = 'https://httpbin.org/'; $data = [ 'date' => date('Y-m-d'), 'service' => 'ME', 'token' => 'empty' ]; $method = 'GET'; $headers = []; $options = []; $request = new MyRequests(); $request->debugStatus = TRUE; $request->debugLoggerPath = '/your/to/path/save_log'; $request->__construct(); $request->setHeader($headers); $request->setOptions($options); echo $request->getVersion(); // Print: 0.1.3.4 $guzzlePhpRequest = $request->guzzlePhpRequest($url, $data, $method); d($guzzlePhpRequest); $curlRequest = $request->curlRequest($url, $data, $method); d($curlRequest); $sendRequest = $request->sendRequest($url, $data, $method); d($sendRequest);
使用文件获取内容发送请求
<?php require '/your/to/path/vendor/autoload.php'; use nguyenanhung\MyRequests\GetContents; // Test Data $url = 'https://httpbin.org/'; $data = [ 'date' => date('Y-m-d'), 'service' => 'ME', 'token' => 'empty' ]; $method = 'GET'; // Let's Go $content = new GetContents(); $content->setURL($url); $content->setMethod($method); $content->setData($data); $content->sendRequest(); echo $content->getVersion(); // Print: 0.1.3.4 $response = $content->response(); $getContent = $content->getContent(); $getError = $content->getError(); d($response); d($getContent); d($getError);
使用SOAP请求发送请求
<?php require '/your/to/path/vendor/autoload.php'; use nguyenanhung\MyRequests\SoapRequest; $soap = new SoapRequest(); $soap->debugStatus = true; $soap->debugLoggerPath = '/your/to/path/save_log'; $soap->__construct(); $soap->setEndpoint('url'); $soap->setCallFunction('function'); $soap->setData($data); $result = $soap->clientRequestWsdl(); echo $soap->getVersion(); // Print: 0.1.3.4 d($result);
联系方式
如有任何疑问和要求,请通过以下信息联系
来自河内的爱 <3