hello dopelabs, Yes I did and I have tried it many times without success. I downloaded both scripts and created the title.txt file as well. Here it is my twittercast.php script:
==========================================
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?
// Twittercast Shoutcast Twitter Status Script By DopeLabs -
http://www.dubstep.fm
<?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] = "http://38.96.148.45";
$port[1] = "8186";
$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]);
}
fclose($fh);
?>
</body>
</html>
===============================================
And this is my Twitter API script:
==================================
<html>
<body>
<?php
// A simple function using Curl to post (GET) to Twitter
// Kosso : March 14 2007
$twitter_username ='chevereradiotv';
$twitter_psw ='xxxxxxxxx';
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 sended! <a href="http://twitter.com/'.$username.'">See your profile</a>';
} else {
$twitter_status="Error posting to Twitter. Retry";
}
return $twitter_status;
}
?>
</body>
</html>
=======================
Any help will greatly appreciated.