PHP code example of alex-kalanis / remote-request

1. Go to this page and download the library: Download alex-kalanis/remote-request library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alex-kalanis / remote-request example snippets


    $libParams = new RemoteRequest\Connection\Params\Ssl();
    $libParams->setTarget('10.0.0.1', 2048);

    $libQuery = new RemoteRequest\Protocols\Http\Query(); # http internals
    $libQuery
        ->setMethod('post')
        ->setRequestSettings($libParams)
        ->setPath('/api/hook/')
        ->addValues([
            'service_id' => $serviceId,
            'hook_data' => $data,
        ])
    ;

    $libProcessor = new RemoteRequest\Connection\Processor(); # tcp/ip http/ssl
    $libProcessor->setConnectionParams($libParams);
    $libProcessor->setData($libQuery);

    $libHttpAnswer = new RemoteRequest\Protocols\Http\Answer();
    $response = $libHttpAnswer->setResponse($libProcessor->getResponse());
    return $response->getContent();

    return RemoteRequest\Helper::getRemoteContent(
        'https://10.0.0.1:2048/api/hook/',
        [
            'service_id' => $serviceId,
            'hook_data' => $data,
        ], [
            'method' => 'post',
            'multipart' => true,
        ]
    );

    $libParams = new RemoteRequest\Connection\Params\Udp(); # query params on layer 3
    $libParams->setTarget('udp-listener.' . DOMAIN, 514);

    $message = new RemoteRequest\Protocols\Dummy\Query();
    $message->maxLength = 0; // expects no response
    $message->body = 'Post message to them!';

    $libProtocol = new RemoteRequest\Connection\Processor();
    $libProtocol->setProtocolSchema($libParams)->setData($message);
    $libProtocol->getResponse(); // just execute

    RemoteRequest\Helper::getRemoteContent(
        'udp://udp-listener.' . DOMAIN . ':514',
        'Post message to them!'
    );