Example of using curl to issue an authenticated REST request.
<?php // Demonstrates two methods of including authorisation // for accessing a resource // The resource in this case is an xml export of the account // table of document Acme.moneyworks if($_GET["auth"] == "headers") { $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:6710/REST/Acme.moneyworks/ export/table=account&format=xml-terse"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // set Auth headers for Datacentre login, and document login $headers = array( "Authorization: Basic " . base64_encode("root:Datacentre:XXXX"), "Authorization: Basic " . base64_encode("Admin:Document:fred")); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); curl_close($ch); } else if($_GET["auth"] == "inline") { $ch = curl_init(); // usernames and passwords are inline in the URL // ask for verbose output so we can see the difference curl_setopt($ch, CURLOPT_URL, "http://root:XXXX@127.0.0.1:6710/ REST/Admin:fred@Acme.mwd6/export/ table=account&format=xml-verbose"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); } header("Content-Type: text/xml"); echo $result; ?>