Skip to content

Instantly share code, notes, and snippets.

@anovikov1984
Created November 9, 2015 17:02
Show Gist options
  • Save anovikov1984/eca243f0b0c0c74770a3 to your computer and use it in GitHub Desktop.
Save anovikov1984/eca243f0b0c0c74770a3 to your computer and use it in GitHub Desktop.
Fetching environment variables and generating a JSON response using them
<?php
header('Content-Type: application/json');
$publishKey = trim(getenv("PUBNUB_PUBLISH_KEY"));
$subscribeKey = trim(getenv("PUBNUB_SUBLISH_KEY"));
if (empty($publishKey)) {
$publishKey = "demo";
}
if (empty($subscribeKey)) {
$subscribeKey = "demo";
}
echo '{"publish_key": "' . $publishKey . '", "subscribe_key": "' . $subscribeKey . '"}';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment