Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scaledrone PHP REST push example
<?php
$channel_id = "CHANNEL_ID_FROM_SCALEDRONE_DASHBOARD";
$channel_secret = "CHANNEL_SECRET_FROM_SCALEDRONE_DASHBOARD";
$room_name = "roomName";
$auth = base64_encode("$channel_id:$channel_secret");
$url = "https://api2.scaledrone.com/$channel_id/$room_name/publish";
$data = array('key1' => 'value1', 'key2' => 'value2');
$options = array(
'http' => array(
'header' => array(
"Content-type: application/json",
"Authorization: Basic $auth",
),
'method' => 'POST',
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment