Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.14 KB

README.md

File metadata and controls

55 lines (38 loc) · 1.14 KB

cas-rest-client

PHP client for the CAS REST protocol

System Requirements

You need:

  • PHP >= 5.5.0, but the latest stable version of PHP is recommended
  • Composer

Install

Install cas-rest-client using Composer.

$ composer require epierce/cas-rest-client

Example Usage

<?php

use epierce\CasRestClient;

require_once('vendor/autoload.php');

$client = new 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();

?>