https://github.com/goindow/php-curl
CurlUtil.php 是对 PHP CURL的封装
https://github.com/goindow/php-curl
php-curl
Last synced: about 1 month ago
JSON representation
CurlUtil.php 是对 PHP CURL的封装
- Host: GitHub
- URL: https://github.com/goindow/php-curl
- Owner: goindow
- License: mit
- Created: 2018-04-03T08:29:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T09:58:50.000Z (about 7 years ago)
- Last Synced: 2025-01-21T16:23:15.367Z (3 months ago)
- Topics: php-curl
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CurlUtil
CurlUtil.php 是对 PHP CURL 的封装。使用单例模式,封装了最常用的 http/https 的 get/post 请求,内置支持 application/x-www-form-urlencoded 及 application/json 数据格式,便利的 header 配置,ssl 链式支持等
## Usage
* Init
```php
const API_URL = '';$postData = [
'page': 1,
'size': 15
// more data
];$curl = CurlUtil::getInstance();
```* Get
```php
$curl->get(API_URL);
```* Post (formData )
```php
$curl->get(API_URL);
```* Post (jsonData)
```php
$curl->post(API_URL, $postData, true);
```* Https
```php
$curl->ssl()->get(API_URL);
$curl->ssl()->post(API_URL, $formData);
$curl->ssl()->post(API_URL, $postData, true);
```