PHP code example of epierce / cas-rest-client

1. Go to this page and download the library: Download epierce/cas-rest-client 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/ */

    

epierce / cas-rest-client example snippets




use epierce\CasRestClient;

/ Configure CAS client
$client->setCasServer('https://cas.exmaple.edu');
$client->setCasRestContext('/v1/tickets');
$client->setCredentials("username", "password");

// Login and save TGT to a file
$client->login('/tmp/cas_tgt.json');

// Make a webservice call
$response = $client->get("https://someservice");
print_r(json_decode($response->getBody(), true));

// Make another call using the same CAS session
$headers = ['User-Agent' => 'testing/1.0'];
$post_params = ['param1' => 'foo', param2 => 'bar'];
$response = $client->post("https://someotherservice", $headers, '', $post_params);
print_r(json_decode($response->getBody(), true));

$client->logout();