I’ve tested many already created hosting sites where you can grab stats from your stream and auto tweet it and they don’t turn out to work as well.
I’ve considered writing my own code as I’m a PHP developer myself, but since theirs tools already out their; I figure I’ll try and see if there was some sort of already created solution out there. Thus bringing me too this forum thread and decided to give this “twitter script” a shot.
After 5 minutes of downloading, creating twitter application, getting APIs and tokens, updating configuration, setting file permissions and tested via browser. It does it work! After browser test I’ve moved to using a cron job – and still works.
Thus be the reason I’m posting now, I’ve noticed a few people have struggled getting this to work and I’ve tested this on CentOS with cPanel running Apache.
The following details that says “MediaOnAir” represents my company name – and I used for this test, please use your own radio station name when creating your application for twitter. Keep in mind – where ever you want your song displayed on your twitter account you MUST log into that account to create an application.
After you submit your application will automatically be created and you have API keys instantly.
Now we’re going to update the twitter.php file, open twitter.php in your favorite editor, if you don’t have one you can open in notepad.
I’ve labeled above where each key goes where based on the variable presented in the twitter.php.
After you fill in those details – you will notice a ‘red box’ that points to ‘Click here’ this is your access token which is required.
Again, I’ve labled where each token goes where in the twitter.php file.
Now we need to update the radio settings to get the information, change these settings to your host and port.
$ip = "22.214.171.124";
$port = "8000";
If you have more than one stream than you need to do the same for the other ports. You can add by copy and pasting and changing to the next number.
$ip = "126.96.36.199";
$port = "8000";
Or just remove all but 1.
After completed, save twitter.php – name the folder whatever you like and upload to your document root directory for it to be web accessiable, As mentioned earlier, I run cPanel therefore my doc root would be public_html – and I named my folder ‘twitter’ and uploaded it with all files inside.
If you right-click on title.txt in your FTP client (I use FileZilla) goto properties or could also be permissions if you’re using a different client – You need to set these permissions to 777 – make sure all boxes are checked or you can just type 777 in the input field. Again, I use cPanel chmod can also be done via the file manager.
After this, we can now being testing via the browser.
Web Test 1:
Success! – Does it post to twitter?
Twitter Test 1:
Success – Let’s try this again after browser refresh.
Web Test 2:
Success – Does it post to twitter?
Twitter Test 2:
Success! – Now let’s add cron job.
First, we need to add the cron job, most control panels support this as I use cPanel it does and even makes it easy for you. If you don’t use cPanel – ask your host if you’re unsure about adding cron jobs. All configurations will be more less the same.
Login cPanel – and go to Cron Jobs.
In cPanel theirs a dropdown box, Select ‘Common Settings: Every minute (*****) I’ve tested this to make sure it doesn’t double post or anything and it don’t.
You need to chage the command to use your own domain name;
Most people copy and paste ***** in the command line, do not do this! – Copy from wget as shown above.
Add New Cron Job; Close Browser and Let’s Test!
Shoutcast DNAS Test:
Twitter Test 3:
After a few minutes it’s posted for a few songs.
You can alter data if you know how to display your website or remove item’s – If you notice I’ve removed the listeners and added a website url. If you don’t know PHP than I don’t recommend updating this, if you want a certain way to be display ask here and I’m sure me or others will be willing to help.
Lastly, 7.html has been deprecated in Shoutcast V2 – therefore it will not work – but theirs already scripts out there that support logging into Shoutcast and grabbing the XML data to display the song data, I’ll possibly update this to get this working.