Hello i've tried to connect to the Twitch IRC Chat so i can try to make a simple chat bot for twitch but im struggling to make it work.
Error im getting: http://puu.sh/j3HwK/173a0388fb.png
and here is the code:
<?php
set_time_limit(0);
ini_set('display_errors', 'on');
function IRCBot()
{
function IRC()
{
$config = array(
'server' => 'irc.twitch.tv',
'port' => 6667,
'channel' => '#spiritboar',
'name' => 'bin4rybot',
'nick' => 'Bin4ryBOT',
'pass' => 'oauth:##########################' //http://twitchapps.com/tmi/
);
echo 'test';
$server = array();
$server['connect'] = fsockopen($config['server'], $config['port']);
if($server['connect'])
{
echo 'test2';
SendData("PASS " . $config['pass'] . "\n\r");
SendData("NICK " . $config['nick'] . "\n\r");
SendData("USER " . $config['nick'] . "\n\r");
SendData("JOIN " . $config['channel'] . "\n\r");
while(!feof($server['connect']))
{
echo 'test3';
}
}
}
function SendData($cmd)
{
global $server;
fwrite($server['connect'], $cmd, strlen($cmd));
echo "[SEND] $cmd <br>";
}
IRC();
}
IRCBot();
?>
So basicly i cant make it connect to the Twitch IRC, Please if someone can help me it would be much appreciated! :)