use WWW::Mechanize;
$password = "******";
$url = "https://www.chess.com/login";
my $mech = WWW::Mechanize->new();
$cookie_jar = HTTP::Cookies->new( );
$mech->cookie_jar( $cookie_jar );
$mech->get($url);
$mech->submit_form(
form_id => "LoginForm",
fields => { username=>"tenny", password => $password },
);
die "hmmm" unless ($mech->success);
$mech->get("http://live.chess.comlive?v=2014060601");
$req = HTTP::Request->new(POST => 'http://live.chess.com/cometd/');
$req->header(Host=> 'live.chess.com',
User-Agent=> 'Mozilla/5.0 (Windows NT 5.1; rv=>14.0) Gecko/20100101 Firefox/14.0.1',
Accept=> '*/*',
Accept-Language=> 'nl,en-us;q=0.7,en;q=0.3',
Accept-Encoding=> 'gzip, deflate',
Connection=> 'keep-alive',
Content-Type=> 'application/json;charset=UTF-8',
X-Requested-With=> 'XMLHttpRequest',
Referer=> 'http://live.chess.com/live?v=2014060601',
Content-Length=> 141,
Cookie=> 'Cookie: chess_mw_c16=0; tf_login_id=tenny; cal=eGOaKyvdaqatJQ9o6eYICNuw2YJh2%2FunOUYdbS2Jrxf2zmZc7rH8GGGJNqW5%2Bu31tOygjDSTb%2BP8NpPiv3gqnLkVQvzCUvNcXH%2BuQ2pFHVfAYjBRZ0e0CBIUB%2BFji7OLsUTdGgXy3qN%2FXHBjMXncOmrFm9OikTOGaGsiboJNlHE%3D; PHPSESSID=ihirv1mdt9lhtl94c2jut4r3c5; BAYEUX_BROWSER=cf61583lxupwtz2yhwen1hjh2k6; __gads=ID=2810c673b5b73739:T=1402735047:S=ALNI_MZmG2Hxc2r0d4eiM4JMHXglgcofXg',
Pragma=> 'no-cache',
Cache-Control=> 'no-cache');
$req->content('{"channel":"/service/user","data":{"txt":"very bad connection today","id":"R1","sid":"cserv","tid":"Chat"},"id":"2730","clientId":"o"}');
$res = $mech->request($req);
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
####
('{"clientFeatures":{"protocolversion":"1.03","clienttype":"LC4Full","clientname":"LC4Full v2014060601; Firefox/14; Windows","multiplegames":true,"examineboard":true},"serviceChannels":["/service/user","/service/tournament","/service/game","/service/examine"],"version":"1.0","minimumVersion":"1.0","channel":"/meta/handshake","supportedConnectionTypes":["long-polling","ssl-long-polling","callback-polling"],"advice":{"timeout":60000,"interval":0},"id":"1","ext":{"ack":true,"timesync":{"tc":1402752382334,"l":0,"o":0}}}')
####
[{"id":"1","error":"403::Handshake denied","successful":false,"advice":{"reconnect":"none"},"channel":"/meta/handshake","ext":{"timesync
{"ts":1402994052362,"t
c":1402752382334,"a":-241670028,"p":4},"hfdetails":"authentication-failed"}}]