PHP code example of ph-7 / ph7client

1. Go to this page and download the library: Download ph-7/ph7client 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/ */

    

ph-7 / ph7client example snippets






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 = "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