ibuildwebapps / gobble
此包的最新版本(dev-master)没有可用的许可信息。
简化 http 请求。
dev-master
2021-10-14 12:28 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-14 19:20:25 UTC
README
composer require ibuildwebapps/gobble:dev-master
简化版的 curl 包装器。这是作为 Guzzle 的一个更简单的替代品构建的。
GET 示例
$uri = "https://www.google.com" ;
$gobble = new Gobble($uri) ;
//$gobble->setMethod('GET'); /* This is implied */
$gobble->send() ;
$body = $gobble->getResponseBody() ;
$code = $gobble->getResponseCode() ;
echo 'Response body: ' . $body . "\n";
echo 'Response code: ' . $code . "\n";
POST 示例
$uri = "https://www.google.com" ;
$gobble = new Gobble($uri) ;
$gobble->setMethod('POST');
$gobble->setData([$param => $value]);
$gobble->send() ;
$body = $gobble->getResponseBody() ;
$code = $gobble->getResponseCode() ;
echo 'Response body: ' . $body . "\n";
echo 'Response code: ' . $code . "\n";