定制 darkfriend/php5-curl 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

darkfriend/php5-curl

Composer 安装命令:

composer require --dev darkfriend/php5-curl

包简介

PHP5 curl helper

README 文档

README

composer require darkfriend/php5-curl

  • CurlHelper::getInstance($newSession = false, $options = []) - return instance CurlHelper
  • CurlHelper::getInstance($newSession = false, $options = [])->request($url, $data = [], $method = 'post', $requestType = '', $responseType = 'json') - do request to url

Support request method type

  • post
  • get
  • put
  • delete
  • options
  • custom

Support request type

  • json
  • xml
  • custom

Support response type

  • json
  • xml
  • custom

Example1

$url = 'http://site.ru';
$curl = \darkfriend\helpers\CurlHelper::getInstance();
$response = $curl->request($url);

// $response - array response site.ru
// $curl->lastCode - response http code
// $curl->lastHeaders - response http headers

Example2: CurlHelper with custom headers

$url = 'http://site.ru';
$curl = \darkfriend\helpers\CurlHelper::getInstance();
$response = $curl->setHeaders([
            'Accept-Language' => 'ru-RU',
            'Custom-Head' => 'custom',
        ])
        ->request($url);

// $response - array response site.ru
// $curl->lastCode - response http code
// $curl->lastHeaders - response http headers

Example3: CurlHelper with debug

$url = 'http://site.ru';
$curl = \darkfriend\helpers\CurlHelper::getInstance(false,[
    'debug' => true,
    'debugFile' => __DIR__.'/logs'
]);
$response = $curl->request($url);

// $response - array response site.ru
// $curl->lastCode - response http code
// $curl->lastHeaders - response http headers

统计信息

  • 总下载量: 2.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-12-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固