Skip to content

Instantly share code, notes, and snippets.

@herkyl
Last active March 29, 2018 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herkyl/9aa1329efb77a91c9bbe1565b532d21c to your computer and use it in GitHub Desktop.
Save herkyl/9aa1329efb77a91c9bbe1565b532d21c to your computer and use it in GitHub Desktop.
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