Have you seen the cat ears that light up via viewer controlled buttons using MixPlay on Mixer? If you haven’t – here is a guide on how to make them.
But wouldn’t it be cool if every time a stream donation came in, the LED cat ears lit up? Well this is exactly what Lychi & I wanted to do for this week’s charity event, but there was no easy way to do it… until meow!
I had to figure out a way to get alerted when a donation gets in – so I thought the banner, which gets updated each time, would be the perfect target. The next thing I had to figure out is how to send a web request to the LED cat ears to trigger a pattern. I am using xampp 1.7.7 on Windows 10 to do this, so if you have issues with replication, use that version.
So let’s begin!
- Install xampp and start Apache from the control panel
- Go to http://localhost on any browser to confirm Apache is running
- Create a new folder called checker in the C:\xampp\htdocs\ directory
- Create a new file called checker.php in C:\xampp\htdocs\checker directory
- Open checker.php in your most tolerable text editor and get ready to copy paste and modify
Code time!
This will keep refreshing the page to check for changes – modify the $sec value if you need it slower or quicker for whatever reason.
<?php $page = $_SERVER['PHP_SELF']; $sec = ".5"; ?>
The next few lines check for changes in the website by comparing the hash every few seconds. Anything before the } else { will run when no site changes occur [no donation], and anything after the } else { triggers after site changes [donation occurred].
If you wish to do something else other than a web request, remove $remote = fopen(“http://[WEB REQUEST]”, “r”); & fpassthru($remote); and put something else in there that you want triggered when a donation occurs. Be sure to add your event where it states [EVENT NAME HERE] as well.
<?php $contents = file_get_contents('https://tiltify.com/events/[EVENT NAME HERE]/overlay/dashboard'); $hash = file_get_contents('hash'); if ($hash == ($pageHash = md5($contents))) { } else { $remote = fopen("http://[WEB REQUEST]", "r"); fpassthru($remote); $fp = fopen('hash', 'w'); fwrite($fp, $pageHash); fclose($fp); } ?>
And lastly, some HTML.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'"> <title>Donation Checker</title> </head> <body> Checking for donations... </body> </html>
I’m not sure how useful this will be for anyone else other than Lychi but hey, I figured I’d post it in case someone else is trying to do something similar and is having issues figuring it out. I know the guide is far from perfect, so if there are any issues with this or if you have questions feel free to ask them below! 🙂
Love you like tacos,
sorryaboutyourcats