Example Domain

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Простой НТТР(S) клиент на PHP7+ с троттлингом запросов, поддержкой маркера BOM в теле сообщения формата JSON и выводом отладочной информации в STDOUT.

License

andrey-tech/http-client-php

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Читайте также:  Java paint set color

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Простой НТТР(S) клиент на PHP7+ с троттлингом запросов, поддержкой маркера BOM в теле сообщения формата JSON и выводом отладочной информации о запросах и ответах в STDOUT.

$ composer require andrey-tech/http-client-php:"^3.0" 
"andrey-tech/http-client-php": "^3.0" 

в секцию require файла composer.json.

Класс \App\HTTP\НТТР обеспечивает:

  • выполнение запросов по протоколу НТТР(S);
  • настраиваемый троттлинг запросов;
  • проверку SSL/TLS-сертификата сервера c возможностью ее отключения;
  • удаление или добавление маркера ВОМ в тело сообщений формата JSON;
  • вывод отладочной информации о запросах и ответах в STDOUT.

При возникновении ошибок выбрасывается исключение класса \App\HTTP\HTTPException .

  • __construct() Конструктор класса.
  • request(string $url, string $method = ‘GET’, array $params = [], array $requestHeaders = [], array $curlOptions = []) :?array
    Отправляет запрос по протоколу HTTP(S). Возвращает декодированный ответ сервера или null при возникновении ошибки cURL.
    • $url — URL запроса;
    • $method — метод запроса;
    • $params — параметры запроса;
    • $curlOptions — дополнительные параметры для cURL.
    • $successStatisCodes Коды статуса НТТР, соответствующие успешному выполнению запроса. Если не передан, то используется значение по умолчанию, установленное в свойстве $successStatusCodes .

    Дополнительные параметры устанавливаются через публичные свойства объекта класса \App\HTTP\HTTP :

    Свойство По умолчанию Описание
    $debugLevel \App\HTTP\HTTP::DEBUG_NONE Устанавливает уровень вывода отладочной информации о запросах в STDOUT (битовая маска, составляемая из значений DEBUG_NONE, DEBUG_URL, DEBUG_HEADERS, DEBUG_CONTENT)
    $throttle 0 Максимальное число HTTP запросов в секунду (0 — троттлинг отключен)
    $addBOM false Добавлять маркер ВОМ UTF-8 (EFBBBF) к запросам в формате JSON
    $useCookies false Использовать cookies в запросах
    $cookieFile ‘temp/cookies.txt’ Путь к файлу для хранения cookies
    $verifySSLCertificate true Включить проверку SSL/TLS-сертификата сервера
    $SSLCertificateFile ‘cacert.pem’ Устанавливает файл SSL/TLS-сертификатов X.509 корневых удостоверяющих центров (CA) в формате РЕМ (установка в null означает использовать файл, указанный в параметре curl.cainfo файла php.ini)
    $userAgent ‘HTTP-client/3.x.x’ Устанавливает НТТР заголовок UserAgent в запросах
    $curlConnectTimeout 60 Устанавливает таймаут соединения, секунды
    $curlTimeout 60 Устанавливает таймаут обмена данными, секунды
    $successStatusCodes [ 200 ] Коды статуса НТТР, соответствующие успешному выполнению запроса
    use App\HTTP\HTTP; use App\HTTP\HTTPException; try < // Создаем клиента $http = new HTTP(); // Устанавливаем максимальный уровень вывода отладочных сообщений в STDOUT $http->debugLevel = HTTP::DEBUG_URL | HTTP::DEBUG_HEADERS | HTTP::DEBUG_CONTENT; // Устанавливаем троттлинг запросов на уровне не более 1 запроса в 2 секунды $http->throttle = 0.5; // Устанавливаем таймаут соединения в 30 секунд $http->curlConnectTimeout = 30; // Устанавливаем таймаут обмена данными в 30 секунд $http->curlTimeout = 30; // Отправляем POST запрос $response = $http->request( $url = 'https://www.example.com', $method = 'POST', $params = [ 'username' => 'ivan@example.com', 'password' => '1234567890' ], $requestHeaders = [ 'Content-Type: application/json' ] ); // Проверяем НТТР статус ответа if (! $http->isSuccess()) < $httpCode = $http->getHTTPCode(); $response = $http->getResponse(); throw new HTTPException("HTTP $httpCode>: $response>"); > print_r($response); > catch (HTTPException $e) < printf('Ошибка (%d): %s' . PHP_EOL, $e->getCode(), $e->getMessage()); >

    Пример отладочных сообщений:

    [1] ===> POST https://www.example.com POST / HTTP/1.1 Host: www.example.com User-Agent: HTTP-client/3.x.x Accept: */* Content-Type: application/json Content-Length: 55 [1]      

    Example Domain

    This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.

    More information.

    Источник

    Saved searches

    Use saved searches to filter your results more quickly

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

    bagia/WebClient.PHP

    This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

    Name already in use

    A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

    Sign In Required

    Please sign in to use Codespaces.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching Xcode

    If nothing happens, download Xcode and try again.

    Launching Visual Studio Code

    Your codespace will open once ready.

    There was a problem preparing your codespace, please try again.

    Latest commit

    Git stats

    Files

    Failed to load latest commit information.

    README.md

    WebClient.PHP is a PHP class based on the php_curl extension that helps navigating remote websites.

     require_once('./src/WebClient.php'); $webClient = new WebClient(); if( !($html = $webClient->Navigate( "http://example.com/" )) ) < trigger_error( "Could not load the index page.", E_USER_ERROR ); > $postArray = $webClient->getInputs(); $postArray["username"] pl-s">bagia"; $postArray["password"] pl-s">password"; if( !($html = $webClient->Navigate( "http://example.com/login.php", $postArray )) ) < trigger_error( "Could not load the login page.", E_USER_ERROR ); > echo $html; ?>

    Источник

    Saved searches

    Use saved searches to filter your results more quickly

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

    pH7Client is a PHP Web client class that simulates a Web browser (like a Web Driver) for retrieving webpage content, login to websites and posting forms and makes them on autopilot. With pH7Client, create rules on cron to automate almost all Web routines. It is a bit like FirefoxDriver Selenium.

    pH-7/pH7Client

    This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

    Name already in use

    A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

    Sign In Required

    Please sign in to use Codespaces.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching Xcode

    If nothing happens, download Xcode and try again.

    Launching Visual Studio Code

    Your codespace will open once ready.

    There was a problem preparing your codespace, please try again.

    Latest commit

    Git stats

    Files

    Failed to load latest commit information.

    README.md

    pH7Client — Make your Tasks on Autopilot by Automating them!

    pH7Client is a wonderful tool if you need to automate tasks (like posting articles every day to your blog, add message in a member area, etc) and save lot of times everyday! 😃 Yes! The pH7Client bot can do almost everything (you just need to create some rules and need to know the input name of the website’s forms). In fact, it’s a PHP Web client class that simulates a Web browser for retrieving webpage content, login to websites and posting forms, .

    Finally, you have created rules that you want to automate by pH7Client, you need to setup a cron for executing the script every X time on a server (Type crontab -e on your server Linux terminal, then add the desired cron jobs and save it). Once finished, go to the beach, order a mojito and enjoy your REAL free time that you really deserved!

    You can add it easily in your project by using Composer.

    composer require ph-7/ph7client

    Then, include Composer’s autoload

    require_once 'vendor/autoload.php';

    Manual Installation (the old-fashioned way)

    If you don’t use Composer, you can install it without Composer by simply including the class

    use PH7\External\Http\Client\PH7Client; $sUrl = 'http://ph2date-soft-example.com'; $sRequest1 = 'user/login/'; $sRequest2 = 'user/message_box/myuser920'; $sUser = 'test@ph2date.com'; $sPass = 'testpass123'; $sBody pl-s">Hey! What's up today? Psst! I'm a bot but I may understand you. "; $oWebClient = new PH7Client($sUrl); /***** Log a user *****/ $aLogin = [ 'identity' => $sUser, 'password' => $sPass, 'remember' => 'on', 'submit' => 'Login' ]; // Login the user $oWebClient->post($sRequest1, $aLogin); // Submit the form $oWebClient->send(); /***** Send a message *****/ $aMsg = ['message' => $sBody]; // Send the message $oWebClient->post($sRequest2, ['message' => $sBody])->setHeader(false)->send(); echo $oWebClient->getResponse(); // Will show the successful message telling you that your msg has been send

    I’m Pierre-Henry Soria, young PHP software developer living currently in the Wonderful Manchester city, in the UK.

    You can send an email at pierrehenrysoria [AT] gmail COM or at phy hizup [D0T] UK

    Need a Social/Dating Networking Builder?

    Have a look to my Social Dating Web Builder

    I’m building this software in order to allow people to build Amazing Social/Dating Businesses really easily with almost no money!

    This project is under GPLv3 license! Enjoy!!

    Psst!! By the way, Feel free to contribute to it! If you can, That would be really amazing!

    About

    pH7Client is a PHP Web client class that simulates a Web browser (like a Web Driver) for retrieving webpage content, login to websites and posting forms and makes them on autopilot. With pH7Client, create rules on cron to automate almost all Web routines. It is a bit like FirefoxDriver Selenium.

    Источник

Оцените статью