定制 srvclick/scurl 二次开发

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

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

srvclick/scurl

最新稳定版本:1.0.0.9

Composer 安装命令:

composer require srvclick/scurl

包简介

Easy PHP Curl Library

README 文档

README

Easy PHP CURL Library

Installation

composer require srvclick/scurl

IMPORT

use Srvclick\Scurl\Scurl_Request as SCURL;

Examples

GET REQUEST

$curl = new SCURL;
$curl->setUrl('https://example.com');
$response = $curl->Send();
echo $response->getBody();

POST REQUEST

$curl->setMethod("POST");
$curl->setParameters([
    'user' => 'user',
    'password' => 'password',
]);

Custom Method

$curl->setConfigs([
    'custom_method' => 'PUT'
])

SET PROXY

WITHOUT AUTH
$curl->setProxy([
    'proxy' => '127.0.0.1',
    'proxy_port' => '9090'
]);
WITH AUTH
$curl->setProxy([
    'proxy' => '127.0.0.1',
    'proxy_port' => '9090',
    'proy_user' => 'root',
    'proxy_pass' => 'toor'
]);

SET USER-AGENT

Option 1
$curl->setConfigs([
    'user-agent' => 'Mozilla'
])
Option 2
$curl->setHeaders([
    'user-agent: Mozilla'
])

SSL VERIFY PEER

$curl->setConfigs([
    'ssl_verifypeer' => 'false'
]);

USE COOKIES

$curl->useCookie(true);
$curl->setCookieName('Random Cookie Name');

DOWNLOAD FILES

$curl->downloadFile("/path/","filename.ext");

INTERCEPT COOKIES

$curl->setInterceptCookie(true);
$responseCookies = $response->getResponseCoookies(); //Array

AVAILABLE CONFIGURATIONS

$curl->setConfigs([
    'use_proxy' => true,
    'max_redirs' => 10,
    'timeout' => 30,
    'http_version' => CURL_HTTP_VERSION_1_1,
    'return_transfer' => true,
    'ssl_verifypeer' => true,
    'follow' => false,
    'encondig' => "",
    'user-agent' => 'SCURL by SrvClick',
    'header' => [],
    'http_auth' => true,
    'http_user' => 'admin',
    'http_pass' => 'admin'
]);

MULTI CURL SUPPORT

$curl = new SCURL();
$curl->setMulticurl();
for ($i = 0; $i < 10; $i++) {
    $curl->MultiUrl('https://jsonplaceholder.typicode.com/todos/'.$i);
    $curl->downloadFile(__DIR__."/downloads/","item_".$i.".json");
}
$response = $curl->Send();
for ($i = 0; $i < $response->getCount(); $i++) {
    echo "Peticion ".$i." Con HTTP STATUS ".$response->getStatus($i)."\n";
}

NIP SUPPORT

$curl->NipSetRange($core, $limit);
$curl->NipMultiUrl('https://example.com/nip');
$curl->NipSetParams(function($nip){
        return ['otp' => str_pad($nip ,4,0,STR_PAD_LEFT)];
        //return '{"nip":"'.str_pad($nip ,4,0,STR_PAD_LEFT).'"}'; //Example 2
    }
$response = $curl->Send();

if($response->checkNip(function ($response) {
    $decode = json_decode($response,true);
    if ($decode['success'] == "yes") return true;
    return false;
})){
    echo "NIP: ".$response->getNip()."\n";
}else{
    echo "Nip not found\n";
}
);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-04