When there's live broadcast on youtube there's always a chat to the right of video player. I am trying to download messages from chat to my PHP page in order to filter trough them as they scroll really fast and i cannot catch up with them.
I noticed that when you open youtube page with live chat it runs GET to this URL every 10 seconds
https://www.youtube.com/live_comments?action_get_comments=1&video_id=<video_id><=<timestamp of last recorded message>&format=proto&pd=10000&rc=26&scr=true&comment_version=1
If i do
$xml= file_get_contents('https://www.youtube.com/live_comments?action_get_comments=1&video_id=<video_id><=<timestamp of last recorded message>&format=proto&pd=10000&rc=26&scr=true&comment_version=1');
echo "<textarea>{$xml}</textarea>";
I get following
<?xml version="1.0" encoding="utf-8"?>
<root>
<latest_time>
<![CDATA[1445398692]]>
</latest_time>
<return_code>
<![CDATA[0]]>
</return_code>
<likes_data>
<![CDATA[{"percent_dislikes":7,"num_likes":"1,383","num_dislikes":"91","percent_likes":93}]]>
</likes_data>
<comments>
<![CDATA[EOcKGFsgkE4=]]>
</comments>
</root>
I assume this would get me new messages that appear however i am currently testing on chat that has no people in it and i cannot confirm.
There's also POST request every 10 seconds however i am not trying to post just download.
My question is how do i download with PHP existing messages that show in the chat when you open page initially?
This is not an adequate answer (no PHP, no code...), but if you are interested in a dirty and simple solution (grabbing a Youtube Live video Chat as JSON), you can use your browser to do so. In Firefox: