Skip to content

Instantly share code, notes, and snippets.

@ggramaize
Created October 28, 2018 14:59
Show Gist options
  • Save ggramaize/03e49ba65a753846575787b0aff2dca0 to your computer and use it in GitHub Desktop.
Save ggramaize/03e49ba65a753846575787b0aff2dca0 to your computer and use it in GitHub Desktop.
<?php
$service_url = 'http://www.hampager.de:8080/calls';
$username = 'n0call';
$password = 'geheim';
$body = array(
'text' => "F4HOF: Ceci est un autre test de l'API REST Dapnet. 73",
'callSignNames' => array(
'f4hof'
),
'transmitterGroupNames' => array('all'),
'emergency' => false
);
$reqOpts = array(
'http' =>
array(
'method' => 'POST',
'header' => array(
'Content-Type: application/json',
'Authorization: Basic '. base64_encode($username.':'.$password)
),
'content' => json_encode( $body)
)
);
$sContext = stream_context_create( $reqOpts);
$result = file_get_contents( $service_url, false, $sContext);
if( $result == false )
{
$error = error_get_last();
echo('Request failed: ' . $error['message']);
}
var_dump($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment