diff options
Diffstat (limited to 'modules/twitter/twitter_update.php')
-rw-r--r-- | modules/twitter/twitter_update.php | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/modules/twitter/twitter_update.php b/modules/twitter/twitter_update.php index 9fe779d6..04dbd878 100644 --- a/modules/twitter/twitter_update.php +++ b/modules/twitter/twitter_update.php @@ -1,4 +1,5 @@ <?php +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * Adapted for Ampache by Chris Slamar @@ -22,38 +23,38 @@ * */ - require_once '../../lib/init.php'; - require_once( Config::get('prefix') . "/modules/twitter/twitteroauth/twitteroauth.php"); - session_start(); - - - if(!empty($_SESSION['twitterusername'])) { - - $nowplayingQuery = "SELECT song.title,artist.name FROM song,now_playing,artist WHERE song.id = now_playing.object_id AND artist.id = song.artist"; - debug_event("Twitter", "Now Playing query: " . $nowplayingQuery, "6"); - - $nowplayingRun = Dba::read($nowplayingQuery); - $nowplayingResults = Dba::fetch_assoc($nowplayingRun); - - $return = $nowplayingResults['title'] . " by " . $nowplayingResults['name']; - debug_event("Twitter", "Song from DB is: " . $return, "5"); - - $selectquery = "SELECT * FROM twitter_users WHERE username = '" . $_SESSION['twitterusername'] . "' AND ampache_id = " . $_SESSION['userdata']['uid']; - debug_event("Twitter", "Select query: " . $selectquery, "6"); - - $selectrun = Dba::read($selectquery); - $result = Dba::fetch_assoc($selectrun); - - $twitteroauth = new TwitterOAuth( Config::get('twitter_consumer_key'), Config::get('twitter_consumer_secret'), $result['oauth_token'], $result['oauth_secret']); - $user_info = $twitteroauth->get('account/verify'); - if( $user_info->error == 'Not found' ) { - debug_event("Twitter", "Auth Successful! Posting Status", "5"); - $twitteroauth->post('statuses/update', array('status' => 'is rocking out to ' . $return)); - header('Location: ' . Config::get('web_path') ); - } - - } else { - debug_event("Twitter", "Auth Error going back to home.", "5"); - header('Location: ' . Config::get('web_path') ); - } +require_once '../../lib/init.php'; +require_once( Config::get('prefix') . "/modules/twitter/twitteroauth/twitteroauth.php"); + session_start(); + + +if(!empty($_SESSION['twitterusername'])) { + + $nowplayingQuery = "SELECT song.title,artist.name FROM song,now_playing,artist WHERE song.id = now_playing.object_id AND artist.id = song.artist"; + debug_event("Twitter", "Now Playing query: " . $nowplayingQuery, "6"); + + $nowplayingRun = Dba::read($nowplayingQuery); + $nowplayingResults = Dba::fetch_assoc($nowplayingRun); + + $return = $nowplayingResults['title'] . " by " . $nowplayingResults['name']; + debug_event("Twitter", "Song from DB is: " . $return, "5"); + + $selectquery = "SELECT * FROM twitter_users WHERE username = '" . $_SESSION['twitterusername'] . "' AND ampache_id = " . $_SESSION['userdata']['uid']; + debug_event("Twitter", "Select query: " . $selectquery, "6"); + + $selectrun = Dba::read($selectquery); + $result = Dba::fetch_assoc($selectrun); + + $twitteroauth = new TwitterOAuth( Config::get('twitter_consumer_key'), Config::get('twitter_consumer_secret'), $result['oauth_token'], $result['oauth_secret']); + $user_info = $twitteroauth->get('account/verify'); + if( $user_info->error == 'Not found' ) { + debug_event("Twitter", "Auth Successful! Posting Status", "5"); + $twitteroauth->post('statuses/update', array('status' => 'is rocking out to ' . $return)); + header('Location: ' . Config::get('web_path') ); + } + +} else { + debug_event("Twitter", "Auth Error going back to home.", "5"); + header('Location: ' . Config::get('web_path') ); +} ?> |