Skip to content

Instantly share code, notes, and snippets.

@timmmmyboy
Created August 21, 2020 01:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmmmyboy/df63584b34d27ad53b22e37e52dc9fcc to your computer and use it in GitHub Desktop.
Save timmmmyboy/df63584b34d27ad53b22e37e52dc9fcc to your computer and use it in GitHub Desktop.
<?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