Skip to content

Instantly share code, notes, and snippets.

@JulianWebb
Last active March 8, 2017 02:10
Show Gist options
  • Save JulianWebb/a6e62e6fc2c16111f14afb748a64f7bc to your computer and use it in GitHub Desktop.
Save JulianWebb/a6e62e6fc2c16111f14afb748a64f7bc to your computer and use it in GitHub Desktop.
Nightbot, why?
<?php
echo " ";
define("USERAGENT", "SuperMario/6.4");
$api = "http://warp.world/bot/";
$streamer = $_GET["streamer"];
$key = $_GET["key"];
$type = $_GET["type"]; //"next" or "rand"
$apiUrl = $api . $type . "?streamer=" . $streamer . "&key=" . $key;
$headers = getallheaders();
callBack($headers["Nightbot-Response-Url"], apiCall($apiUrl));
/**
* @param $url String
* @param $data String
*/
function callBack($url, $data) {
$message = "message=" . urlencode($data);
$options = Array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_USERAGENT => USERAGENT,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $message,
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
curl_exec($ch);
}
function apiCall($url) {
$options = Array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_USERAGENT => USERAGENT,
CURLOPT_POST => FALSE,
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
return curl_exec($ch);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment