Created
March 16, 2011 06:42
-
-
Save nus/872110 to your computer and use it in GitHub Desktop.
Boost::asioでニコ生のコメントを取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <boost/asio.hpp> | |
using namespace std; | |
using namespace boost::asio; | |
int main() | |
{ | |
/* | |
ブラウザでニコニコ動画にログインした状態で | |
http://watch.live.nicovideo.jp/api/getplayerstatus?v=lvNNNNN | |
でニコ生のステータスを取得 | |
必要なエレメントは | |
<ms> | |
<addr> msg101.live.nicovideo.jp </addr> | |
<port> 1234 </port> | |
<thread> 1234567890 </threa> | |
</ms> | |
*/ | |
string ms = "msg102.live.nicovideo.jp"; // <addr>msgNNN.live.nicovideo.jp </addr> | |
string port = "2811"; // <port>ポート番号</port> | |
string thread = "1077478504"; // <thread>コメントのスレッドID</thread> | |
ip::tcp::iostream s(ms, port); | |
s << "<thread thread=\"" << thread << "\" version=\"20061206\" res_from=\"-1\"/>"; | |
s << '\0'; | |
s.flush(); | |
string line; | |
while(1) { | |
getline(s, line, '\0'); | |
/* | |
*****</chat>\0<chat thread=****** | |
'\0'で1コメントの区切りだから | |
*/ | |
cout << line << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment