s00d / guzzle-http-request
GHR is a simple Guzzle wrapper + multiple request + DomCrawler
1.0.56
2021-02-24 16:21 UTC
Requires
- php: >=5.5.9
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^6.2
- guzzlehttp/promises: ^1.3
- kevinrob/guzzle-cache-middleware: ~2.0|~3.0
- rtheunissen/guzzle-log-middleware: ^0.4.0
- symfony/dom-crawler: ~2.8|~3.0|~4.0|~5.0
Requires (Dev)
- laravel/lumen-framework: ^7.2
- phpunit/phpunit: ^6.0
- dev-master
- 1.0.56
- 1.0.55
- 1.0.54
- 1.0.53
- 1.0.52
- 1.0.51
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.6
- 1.0.4
This package is auto-updated.
Last update: 2024-10-25 00:46:56 UTC
README
GHR is a simple Guzzle wrapper + multiple request + DomCrawler
Real documentation is in the works, but for now read the tests.
Installation
Require this package in your composer.json
or install it by running:
composer require s00d/guzzle-http-request
To start using Laravel, add the Service Provider and the Facade to your config/app.php
:
'providers' => [ // ... s00d\GuzzleHttpRequest\GHRServiceProvider::class, ]
'aliases' => [ // ... 'GHR' => s00d\GuzzleHttpRequest\Facades\GHRFacade::class, ]
Publish the configurations
Run this on the command line from the root of your project:
php artisan vendor:publish
A configuration file will be publish to config/ghr.php
Basic Usage
use GHR; ... Config::set('ghr.cookie_file', "/cookie/text.txt"); $request = GHR::createRequest()->setProxy('tcp://127.0.0.1:8080')->setRedirects(5)->setHttpErrors(false)->setTimeout(500); $request->addHeader('user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'); $response = $request->setUrl('https://localhost')->setType('POST')->send(); $crawler = $response->getCrawler(); try{ $crawler->filter('.exit')->html(); print_r(Carbon::now()->toTimeString().": Client auth\n"); } catch(\Exception $e) { print_r(Carbon::now()->toTimeString().": Client NOT auth\n"); } $form = $crawler->selectButton('next')->form(); $form->setValues([ 'user' => $user, ]); $response->sendForm($form); var_dump($response->getContents()); var_dump($response->getJson()); ... $response = GHR::createRequest() ->setMultipleFlowCount(10) ->setProxy('tcp://127.0.0.1:8080') ->removeDataParams()->addToQueue('/guzzle-test/get', 'GET', 0) ->setBody(['foo' => 'bar'], 'form_params')->addToQueue('/guzzle-test/post', 'POST', 1) ->setBody(['foo' => 'bar'], 'form_params')->addToQueue('/guzzle-test/put', 'PUT', 2) ->setBody(['foo' => 'bar'], 'form_params')->addToQueue('/guzzle-test/patch', 'PATCH', 3) ->setBody(['foo' => 'bar'], 'form_params')->addToQueue('/guzzle-test/delete'), 'DELETE', 4) ->multipleSend('form_params')->getMultiResp(); var_dump($response->responses()); // all responses var_dump($response->errors()); var_dump($response->finished());