承接 tyasa81/requestwrapper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tyasa81/requestwrapper

最新稳定版本:v1.1.2

Composer 安装命令:

composer require tyasa81/requestwrapper

包简介

Simple Request Wrapper

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a wrapper for request using Guzzle and Curl. It is mainly used to simplify request code in a request heavy project that deals with cookies and proxy. Facade are made for backward compatiblity on previous project where a lot of static methods are used. Refactoring code into a service class and package are made since it made using Guzzle and Curl much cleaner even for projects that are not cookies or proxy centric.

Installation

You can install the package via composer:

composer require tyasa81/requestwrapper

You can publish the config file with:

php artisan vendor:publish --tag="requestwrapper-config"

Usage

Using Facades:

use tyasa81\RequestWrapper\Facades\RequestWrapper;
$response = RequestWrapper::getUrl("https://httpbin.org/ip",true);
dd($response);

Available functions:

    public static function postUrl($url, $payload, $json=false, &$args=array(), $retry=1, $sleep=1, $timeout=15, $type="POST") 
    public static function getUrl($url, $json=false, &$args=array(), $retry=1, $sleep=1, $timeout=15) 
    public static function postMultiPartUrl($url, $multipart, $json=false, &$args=array(), $retry=1, $sleep=1, $timeout=15, $type="POST") 
    public static function getAsync($url_datas, $json=false, $args=array(), $timeout=15) 
    public static function UrlwithProxy($url, $json=false, &$args=array(), $proxy_type="FAST", $type="GET", $retry=5, $sleep=0, $timeout=15) 
    public static function requestCurlProxyRetry($url, $payload, $json=false, &$args=array(), $type="GET", $proxy_type="GLOBAL", $proxy_index=null, $timeout=20,$retry = 4)
    public static function requestCurlProxy($url, $payload, $json=false, &$args=array(), $type="GET", $proxy_type="GLOBAL", $proxy_index=null, $timeout=20)
    public static function requestCurl($url, $payload, $json=false, &$args=array(), $type="GET", $proxy_type=null, $proxy_index=null, $timeout=15,$retry=0,$sleep=0)
    
    // Helpers Functions
    public static function formatCookieJarToString(CookieJar $cookieJar)
    public static function getCookieValue(CookieJar $cookieJar, string $cookieName)
    public static function convertGuzzleCookieJarToSession(CookieJar $cookieJar)
    public static function getCookieJarFromSession(string $session) 

Using Service Class:

    $curlwrapper = new CurlWrapper(cookieJar: $cookieJar);
    $response = $curlwrapper->request(url: "https://httpbin.org/ip", json: true);

OR

    $guzzlewrapper = new GuzzleWrapper(cookieJar: $cookieJar);
    $response = $guzzlewrapper->request(url: "https://httpbin.org/ip", json: true);

Interface:

    request(string $url, $payload=null, bool $json=false, array $headers=array(), string $type="POST", string $proxy_type=null, int $proxy_index=null, int $retry=1, int $sleep=1, int $timeout=15, bool $allow_redirects=null, bool $decode_content=null)

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-23