<?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