Created
August 21, 2020 01:16
-
-
Save timmmmyboy/df63584b34d27ad53b22e37e52dc9fcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Configure Twitter | |
require_once "vendor/autoload.php"; | |
use Abraham\TwitterOAuth\TwitterOAuth; | |
define('CONSUMER_KEY', 'INSERTCONSUMERKEY'); | |
define('CONSUMER_SECRET', 'INSERTCONSUMERSECRET'); | |
define('ACCESS_TOKEN', 'INSERTACCESSTOKEN'); | |
define('ACCESS_TOKEN_SECRET', 'INSERTACCESSTOKENSECRET'); | |
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |
// Get data from webhook and build array | |
$json = file_get_contents('php://input'); | |
$data = json_decode($json, true); | |
if(!empty($data['now_playing']['streamer'])){ | |
if($data['now_playing']['streamer']!='ds106radio4life'){ | |
$status = 'Live with '.$data['now_playing']['streamer'].' playing: '.$data['now_playing']['song']['title'].'. Tune in at https://listen.ds106rad.io/ #ds106radio'; //text for your tweet. | |
$post_tweets = $connection->post("statuses/update", ["status" => $status]); | |
} | |
else{ | |
$status = 'Now playing: '.$data['now_playing']['song']['title'].'. Tune in at https://listen.ds106rad.io/ #ds106radio'; //text for your tweet. | |
$post_tweets = $connection->post("statuses/update", ["status" => $status]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment