User Tools

Site Tools


Sidebar

js#vista.png msort nsort

subetha:hessianphp

Using HessianPHP with Subetha is actually pretty simple once you get Authenticated.

below you will find a simple example script that returns all mailinglists in the Subetha install

<?php
require("hessian/HessianClient.php");

$url = 'http://subetha.domain.tld/api/Admin';

$curl_options = array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_USERPWD => 'admin_user@domain.tld:password',
    CURLOPT_USERAGENT => 'subetha get lists script/1.0 (PHP)',
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => 1,
    CURLOPT_HTTPAUTH => 'CURLAUTH_BASIC',
    CURLOPT_HEADER => 0,
    CURLOPT_SSL_VERIFYPEER => false
);

$options = new HessianOptions();
$options->transport = "CURL";
$options->transportOptions = $curl_options;

class getLists{
	var $skip;
	var $count;
}

$lists = new getLists();

$proxy = new HessianClient($url, $options);
try{
    $lists=$proxy->getLists(2,5);
} catch (Exception $ex){
   // ...handle error
	echo "error: ".$ex;
	exit;
}

var_dump($lists);

as you can see. the most code is needed for the authentication afterwards it's a simple matter of calling the correct methods.

Enjoy

subetha/hessianphp.txt · Last modified: 2020/02/24 11:16 (external edit)