thanks for the info.. although i have not made any changes to my script and it still works properly =]
Announcement
Collapse
No announcement yet.
Twittercast: Shoutcast / Icecast Song Title To Twitter Status PHP Script
Collapse
X
-
It would be cool if you could make this code be able to tweet only when it finds a keyword from the song field or server description field.
So for instance when our DJ's go live they have the word "live broadcast" typed in the server description field and the song title as well.
Then followers would only get tweets when a DJ goes live rather than tweets every 5 mins when a new song plays.
Would this be easy to add in? Seems like it. Anyone up for it?
Comment
-
find the line that posts to twitter in twittercast.php
mine looks like this
put this line beforecode:
$twitter_status=postToTwitter($twitter_username, $twitter_psw, '#Dubstep.fm - Now Playing: '.$song[1] .' - ' .$total_listeners .' Listeners - http://dsfm.tv');
put this line aftercode:
if (strstr($song[1],"[Live!]")){
so the entire thing should look likecode:
}
code:
if (strstr($song[1],"[Live!]")){
$twitter_status=postToTwitter($twitter_username, $twitter_psw, '#Dubstep.fm - Now Playing: '.$song[1] .' - ' .$total_listeners .' Listeners - http://dsfm.tv');
}
where [Live!] is the text being matched
Comment
-
twittercast song names
This is so cool!! Thanks for posting it!!---------------------------------------------------
StreamFinder.com - Add your radio station to our free directory - get more exposure and listeners
Comment
-
Hi, Can anyone help please...
I have this Twitter stats script running from my website and it works fine for my autodj tune titles being posted to my twitter account, only problem is when theres a live show it doesn't post to twitter.
I have my cron hitting the script every one minute
Comment
-
Originally posted by dopelabs
are your live djs passing any song title meta info to the shoutcast server?
heres how the title looks for all my djs live show titles:
LIVE! - djname - showtitle
Comment
-
facebook
Just be careful if your attaching this to the facebook twitter app. I have gotten emails from facebook. Telling me to stop.
Hi, Our systems indicate that you've been misusing certain features on the site. This email serves as a warning. Misuse of Facebook's features or violating Facebook's terms of use may result in your account being disabled. Thanks in advance for your understanding and cooperation. Please refer to http://www.facebook.com/help.php?page=421 for further information. The Facebook Team
I do know other stations are using this on facebook using the twitter app. They are also not disabled from whatever term they or should I say we may be violating.
Any have any insight on this at all?
Comment
-
i stopped using the facebook twitter app because it was a bit too spamy.. my station broadcasts mix sets only.. so it only updates once an hour or longer.. this script was really intended for such stations.. as stations broadcasting single tunes would require an update more frequently... which is most likely why your getting these emails from facebook.
Comment
-
No 'refresh'
I am having a problem with the refresh.. Can anyone tell me why it doesn't auto refresh please?
code:
<?php
$refresh = "60";
$timeout = "5";
$ip[1] = "87.98.169.195";
$port[1] = "8016";
$servers = count($ip);
$i = "1";
while($i<=$servers)
{
$fp = @fsockopen($ip[$i],$port[$i],$errno,$errstr,$timeout);
if (!$fp)
{
$listeners[$i] = "0";
$msg[$i] = "<span class=\"red\">ERROR [Connection refused / Server down]</span>";
$error[$i] = "1";
}
else
{
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp))
{
$info = fgets($fp);
}
$info = str_replace('<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>', "", $info);
$info = str_replace('</body></html>', "", $info);
$stats = explode(',', $info);
if (empty($stats[1]) )
{
$listeners[$i] = "0";
$msg[$i] = "<span class=\"red\">ERROR [There is no source connected]</span>";
$error[$i] = "1";
}
$song[$i] = $stats[6];
}
$i++;
}
require('twitterAPI.php');
$fh = @fopen('title.txt', 'r+');
$track = @fread($fh, filesize('title.txt'));
if ($track == $song[1]."\n"){
fclose($fh);
die(0);
}else{
@fclose($fh); // if it errors, then the file doesn't exist, and the stream was never open
$fh = fopen('title.txt', 'w');
fwrite($fh, $song[1]."\n");
$twitter_status=postToTwitter($twitter_username, $twitter_psw, 'Now Playing : '.$song[1].' => Listen : http://trance.1mix.co.uk/listen.m3u');
}
fclose($fh);
?>Go easy on me...
https://1mix.co.uk
Comment
-
Twittercast..
This is my final script, just change your twitter login and station details, and you are good to go.
Twittercast.php has to be open all the time though and both need to be in the same directory on your server..
Twitter API
<?php
// Twittercast Shoutcast Twitter Status Script By DopeLabs - http://www.dubstep.fm
// A simple function using Curl to post (GET) to Twitter
// Kosso : March 14 2007
$twitter_username ='username';
$twitter_psw ='password';
function postToTwitter($username,$password,$message){
$host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);
curl_close($ch);
if($resultArray['http_code'] == "200"){
$twitter_status='Your message has been sent! <a href="http://twitter.com/'.$username.'">See your profile</a>';
} else {
$twitter_status="Error posting to Twitter. Retry";
}
return $twitter_status;
}
// end of script
?>
<html>
<head>
<meta http-equiv="refresh" content="200">
</head>
<body>
<?php
$timeout = "5"; // Number of seconds before connecton times out - a higher value will slow the page down if any servers are offline
$ip[1] = "your IP";
$port[1] = "Your port";
$servers = count($ip);
$i = "1";
while($i<=$servers)
{
$fp = @fsockopen($ip[$i],$port[$i],$errno,$errstr,$timeout);
if (!$fp)
{
$listeners[$i] = "0";
$msg[$i] = "<span class=\"red\">ERROR [Connection refused / Server down]</span>";
$error[$i] = "1";
}
else
{
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp))
{
$info = fgets($fp);
}
$info = str_replace('<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>', "", $info);
$info = str_replace('</body></html>', "", $info);
$stats = explode(',', $info);
if (empty($stats[1]) )
{
$listeners[$i] = "0";
$msg[$i] = "<span class=\"red\">ERROR [There is no source connected]</span>";
$error[$i] = "1";
}
$song[$i] = $stats[6];
}
$i++;
}
require('twitterAPI.php');
$fh = @fopen('title.txt', 'r+');
$track = @fread($fh, filesize('title.txt'));
if ($track == $song[1]."\n"){
fclose($fh);
die(0);
}else{
@fclose($fh); // if it errors, then the file doesn't exist, and the stream was never open
$fh = fopen('title.txt', 'w');
fwrite($fh, $song[1]."\n");
$twitter_status=postToTwitter($twitter_username, $twitter_psw, 'Now Playing : '.$song[1].' => Listen : your listen url');
}
fclose($fh);
?>
</body>
</html>Go easy on me...
https://1mix.co.uk
Comment
-
That's because the forum has blanked out anything starting with http..
You need to put the correct url in..Go easy on me...
https://1mix.co.uk
Comment
Comment