一个偶然的机会,在某群看到一个类似QQ机器人的玩意在骚动,问那哥们回答说是JAVA写的,原来QQ还能这样玩儿。于是乎,我也就开始骚动了。Let’s go
1.WEBQQ3.0登陆协议
进入WEBQQ, http://web.qq.com/
通过工具分析,可以知道,用户在输入密码之前(也就是输入帐号后),会首先GET一个请求过去
https://ssl.ptlogin2.qq.com/check?uin=58237991&appid=1003903&r=0.5534069868735969
我们只详细分析下这一个请求,看看,这个请求到底携带了什么样的数据
这个GET请求返回ptui_checkVC(’0′,’!TMX’,’\x00\x00\x00\x00\x0e\xe9\x41\xc1′);这样的字符串,其中第一个字符串,’0′代表不需要验证码,’!TMX’这个数据,是等会登陆需要的,第三个字符串加密密码的时候会用到。
附PHP代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * 获取验证码 * * @access public * @param int $uid * @return array */</span> <span style="color: #000000; font-weight: bold;">function</span> check_verify<span style="color: #009900;">(</span><span style="color: #000088;">$uid</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"https://ssl.ptlogin2.qq.com/check?uin=<span style="color: #006699; font-weight: bold;">{$uid}</span>&appid=1003903&r=0.14233942252344134"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cookie</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"confirmuin=0; ptvfsession=b1235b1729e7808d5530df1dcfda2edd94aabec43bf450d8cf037510802aa1a7dbed494c66577479895c62efa3ef35ab; ptisp=cnc"</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIE<span style="color: #339933;">,</span> <span style="color: #000088;">$cookie</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEJAR<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"/ptui_checkVC\('(.*)','(.*)','(.*)'\);/"</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$verify</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">array_slice</span><span style="color: #009900;">(</span><span style="color: #000088;">$verify</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
密码登陆后,监控到这样一个请求
http://ptlogin2.qq.com/login?u={$uid}&p={$passwd}&verifycode={$verify}&webqq_type=10&remember_uin=1&login2qq=1&aid=1003903&u1=http%3A%2F%2Fweb.qq.com%2Floginproxy.html%3Flogin2qq%3D1%26webqq_type%3D10&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert&action=8-38-447467&mibao_css=m_webqq&t=3&g=1
其中有三个参数需要解释一下
u:QQ号
p:加密后的密码
verifycode:验证码
附PHP版登录函数以及加密函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * WEBQQ3.0 新版登陆加密函数 * * @access public * @param string $p * @param string $pt * @param string $vc * @param boolean $md5 * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> jspassword<span style="color: #009900;">(</span><span style="color: #000088;">$p</span><span style="color: #339933;">,</span><span style="color: #000088;">$pt</span><span style="color: #339933;">,</span><span style="color: #000088;">$vc</span><span style="color: #339933;">,</span><span style="color: #000088;">$md5</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #000088;">$md5</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$p</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">(</span><span style="color: #990000;">md5</span><span style="color: #009900;">(</span><span style="color: #000088;">$p</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #000088;">$len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">(</span><span style="color: #000088;">$p</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">(</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;"><</span> <span style="color: #000088;">$len</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$temp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'\x'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">(</span><span style="color: #000088;">$p</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">(</span><span style="color: #990000;">md5</span><span style="color: #009900;">(</span><span style="color: #990000;">strtoupper</span><span style="color: #009900;">(</span><span style="color: #990000;">md5</span><span style="color: #009900;">(</span>hex2asc<span style="color: #009900;">(</span><span style="color: #000088;">$temp</span><span style="color: #009900;">)</span><span style="color: #339933;">.</span>hex2asc<span style="color: #009900;">(</span><span style="color: #000088;">$pt</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">.</span><span style="color: #000088;">$vc</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009933; font-style: italic;">/** * 十六进制转字符 * * @access private * @param string $str * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> hex2asc<span style="color: #009900;">(</span><span style="color: #000088;">$str</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">join</span><span style="color: #009900;">(</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #990000;">explode</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'\x'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">(</span><span style="color: #000088;">$str</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">(</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;"><</span><span style="color: #000088;">$len</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">chr</span><span style="color: #009900;">(</span><span style="color: #990000;">hexdec</span><span style="color: #009900;">(</span><span style="color: #990000;">substr</span><span style="color: #009900;">(</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009933; font-style: italic;">/** * 登录 * * @access public * @param int $uid * @param string $passwd * @param string $verify * @return array */</span> <span style="color: #000000; font-weight: bold;">function</span> login<span style="color: #009900;">(</span><span style="color: #000088;">$uid</span><span style="color: #339933;">,</span> <span style="color: #000088;">$passwd</span><span style="color: #339933;">,</span> <span style="color: #000088;">$verify</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"http://ptlogin2.qq.com/login?u=<span style="color: #006699; font-weight: bold;">{$uid}</span>&p=<span style="color: #006699; font-weight: bold;">{$passwd}</span>&verifycode=<span style="color: #006699; font-weight: bold;">{$verify}</span>&webqq_type=10&remember_uin=1&login2qq=1&aid=1003903&u1=http%3A<span style="color: #009933; font-weight: bold;">%2F</span><span style="color: #009933; font-weight: bold;">%2F</span>web.qq.com<span style="color: #009933; font-weight: bold;">%2F</span>loginproxy.html<span style="color: #009933; font-weight: bold;">%3F</span>login2qq%3D1%26webqq_type%3D10&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert&action=8-38-447467&mibao_css=m_webqq&t=3&g=1"</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #000088;">$url</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEJAR<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"/ptuiCB\('(.*)','(.*)','(.*)','(.*)','(.*)',\s'(.*)'\);/U"</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$verify</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">array_slice</span><span style="color: #009900;">(</span><span style="color: #000088;">$verify</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
登录成功后返回值类似:
ptuiCB(’0′,’0′,’http://web.qq.com/loginproxy.html?login2qq=1&webqq_type=10′,’0′,’登录成功!’, ‘秋风’);
还有一组COOKIE,COOKIE值全都保存起来,待会儿会用到。
到这一步其实还没有真正的登录QQ的聊天接口,继续往下看。
第一次登录成功后,紧接着发送一个POST到http://d.web2.qq.com/channel/login2
POST值(请把参数值用urlencode函数编码)如下:
r={“status”:”online”,”ptwebqq”:”{$ptwebqq}”,”passwd_sig”:””,”clientid”:”{$clientid}”,”psessionid”:null}&clientid={$clientid}&psessionid=null
其中ptwebqq的值来自第一次登录时候的COOKIE值ptwebqq
clientid是个随机数,自己定义就行了
请求后的返回值是一个JSON格式的值,保存起来,后边收发信息时会用到:
到此为止,登陆就完成了。
附PHP版解析Cookie File函数以及登录函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * 解析cookie * * @access public * @return array */</span> <span style="color: #000000; font-weight: bold;">function</span> parse_cookie<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #666666; font-style: italic;">// Netscape HTTP Cookie File</span> <span style="color: #000088;">$cookies</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file</span><span style="color: #009900;">(</span>temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$cookies</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$v</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"/(.*\.qq\.com)<span style="color: #000099; font-weight: bold;">\t</span>(.*)<span style="color: #000099; font-weight: bold;">\t</span>(.*)<span style="color: #000099; font-weight: bold;">\t</span>(.*)<span style="color: #000099; font-weight: bold;">\t</span>(.*)<span style="color: #000099; font-weight: bold;">\t</span>(.*)<span style="color: #000099; font-weight: bold;">\t</span>(.*)<span style="color: #000099; font-weight: bold;">\n</span>/U"</span><span style="color: #339933;">,</span> <span style="color: #000088;">$v</span><span style="color: #339933;">,</span> <span style="color: #000088;">$p</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$data</span><span style="color: #009900;">[</span><span style="color: #009900;">]</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_slice</span><span style="color: #009900;">(</span><span style="color: #000088;">$p</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009900;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009933; font-style: italic;">/** * 获取cookie * * public * @param array $cookie * @return array */</span> <span style="color: #000000; font-weight: bold;">function</span> get_cookie<span style="color: #009900;">(</span><span style="color: #000088;">$cookie</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #000088;">$cookie</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$cookie</span> <span style="color: #339933;">=</span> parse_cookie<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #990000;">is_array</span><span style="color: #009900;">(</span><span style="color: #000088;">$cookie</span><span style="color: #009900;">)</span> <span style="color: #339933;">&&</span> <span style="color: #990000;">count</span><span style="color: #009900;">(</span><span style="color: #000088;">$cookie</span><span style="color: #009900;">)</span><span style="color: #339933;"><=</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$cookie</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$v</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$data</span><span style="color: #009900;">[</span><span style="color: #000088;">$v</span><span style="color: #009900;">[</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">]</span><span style="color: #009900;">]</span> <span style="color: #339933;">=</span><span style="color: #000088;">$v</span><span style="color: #009900;">[</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">]</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009933; font-style: italic;">/** * 真正的登录(上线) * * @access public * @param string $ptwebqq * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> login2<span style="color: #009900;">(</span><span style="color: #000088;">$ptwebqq</span><span style="color: #339933;">,</span><span style="color: #000088;">$clientid</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"http://d.web2.qq.com/channel/login2"</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #000088;">$url</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #0000ff;">"r=%7B<span style="color: #009933; font-weight: bold;">%22s</span>tatus%22%3A<span style="color: #009933; font-weight: bold;">%22o</span>nline%22%2C%22ptwebqq%22%3A%22<span style="color: #006699; font-weight: bold;">{$ptwebqq}</span>%22%2C%22passwd_sig%22%3A%22%22%2C<span style="color: #009933; font-weight: bold;">%22c</span>lientid%22%3A%22<span style="color: #006699; font-weight: bold;">{$clientid}</span>%22%2C%22psessionid%22%3Anull%7D&clientid=<span style="color: #006699; font-weight: bold;">{$clientid}</span>&psessionid=null"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 必须要来路域名</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_REFERER<span style="color: #339933;">,</span> <span style="color: #0000ff;">"http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=2"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// curl_setopt($ch, CURLOPT_HEADER, TRUE);</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEJAR<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
2.传说中的心跳包
顾名思义,心跳包,就是维持一个长连接,让WEBQQ保持在线的一种机制,.这个心跳包非常简单,只需要每隔几秒,或者写一个死循环发起请求就好(长时间不触发此步骤,会导致QQ掉线)
POST地址:http://d.web2.qq.com/channel/poll2
POST值(请把参数值用urlencode函数编码)如下:
r={“clientid”:”{$clientid}”,”psessionid”:”{$psessionid}”,”key”:0,”ids”:[]}&clientid={$clientid}&psessionid={$psessionid}
其中psessionid的值,在第二次登录返回的JSON信息里边能找到
clientid与第二次登录时候的clientid相同
附PHP版心跳请求函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * 心跳包(获取消息) * * @access public * @param string $psessionid * @param int $clientid * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> poll<span style="color: #009900;">(</span><span style="color: #000088;">$psessionid</span><span style="color: #339933;">,</span><span style="color: #000088;">$clientid</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"r=%7B<span style="color: #009933; font-weight: bold;">%22c</span>lientid%22%3A%22<span style="color: #006699; font-weight: bold;">{$clientid}</span>%22%2C%22psessionid%22%3A%22<span style="color: #006699; font-weight: bold;">{$psessionid}</span>%22%2C%22key%22%3A0%2C%22ids%22%3A%5B%5D%7D&clientid=<span style="color: #006699; font-weight: bold;">{$clientid}</span>&psessionid=<span style="color: #006699; font-weight: bold;">{$psessionid}</span>"</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"http://d.web2.qq.com/channel/poll2"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 必须要来路域名</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_REFERER<span style="color: #339933;">,</span> <span style="color: #0000ff;">"http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
3.获取QQ群列表
POST地址:http://s.web2.qq.com/api/get_group_name_list_mask2
POST值(请把参数值用urlencode函数编码)如下:
r={“vfwebqq”:”{$vfwebqq}”}
只有一个参数,很爽对吧?这个值在第二次登录的时候可得到,回头去找找看吧
附PHP版获取群列表函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * 获取群列表 * * @access public * @param string $vfwebqq * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> get_group_name_list_mask<span style="color: #009900;">(</span><span style="color: #000088;">$vfwebqq</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"r=%7B%22vfwebqq%22%3A%22<span style="color: #006699; font-weight: bold;">{$vfwebqq}</span>%22%7D"</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"http://s.web2.qq.com/api/get_group_name_list_mask2"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_REFERER<span style="color: #339933;">,</span> <span style="color: #0000ff;">"http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span><span style="color: #000088;">$post</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
4.获取好友列表
POST地址:http://s.web2.qq.com/api/get_user_friends2
POST值(请把参数值用urlencode函数编码)如下:
r={“h”:”hello”,”vfwebqq”:”{$vfwebqq}”}
vfwebqq的值在第二次登录的时候可得到,回头去找找看吧
(ps:在编辑本文时,发现这个请求链接的POST值已经加了一个参数hash,分析出来源后尽快补上,这对全局影响并不大)
附PHP版获取好友列表函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * 获取好友列表 * * @access public * @param string $vfwebqq * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> get_user_friend<span style="color: #009900;">(</span><span style="color: #000088;">$vfwebqq</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"r=%7B%22h%22%3A%22hello%22%2C%22vfwebqq%22%3A%22<span style="color: #006699; font-weight: bold;">{$vfwebqq}</span>%22%7D"</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"http://s.web2.qq.com/api/get_user_friends2"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_REFERER<span style="color: #339933;">,</span> <span style="color: #0000ff;">"http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> temp_dir<span style="color: #339933;">.</span><span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span><span style="color: #000088;">$post</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
5.发送QQ消息
POST地址:http://d.web2.qq.com/channel/send_buddy_msg2
POST值(请把参数值用urlencode函数编码)如下:
r={“to”:{$from_uin},”face”:606,”content”:”[\”{$msg}\\n\”,[\”font\”,{\”name\”:\”宋体\”,\”size\”:\”10\”,\”style\”:[0,0,0],\”color\”:\”000000\”}]]”,”msg_id”:{$msg_id},”clientid”:”{$clientid}”,”psessionid”:”{$psessionid}”}&clientid={$clientid}&psessionid={$psessionid}
部分参数解释:
to:好友的uin(非QQ号)
content:发送的消息内容
psessionid:在第二次登录返回的JSON信息里边能找到
clientid:与第二次登录时候的clientid相同
附PHP版发送QQ消息函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * 发送QQ消息 * * @access public * @param int $from_uin * @param string $msg * @param string $psessionid * @param int $clientid * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> send_buddy_msg<span style="color: #009900;">(</span><span style="color: #000088;">$from_uin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$psessionid</span><span style="color: #339933;">,</span> <span style="color: #000088;">$clientid</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> static <span style="color: #000088;">$msg_id</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">71830055</span><span style="color: #339933;">;</span> <span style="color: #000088;">$msg_id</span><span style="color: #339933;">++;</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"r=%7B%22to%22%3A<span style="color: #006699; font-weight: bold;">{$from_uin}</span>%2C<span style="color: #009933; font-weight: bold;">%22f</span>ace%22%3A606%2C<span style="color: #009933; font-weight: bold;">%22c</span>ontent%22%3A%22%5B%5C%22<span style="color: #006699; font-weight: bold;">{$msg}</span>%5C%5Cn%5C%22%2C%5B%5C<span style="color: #009933; font-weight: bold;">%22f</span>ont%5C%22%2C%7B%5C%22name%5C%22%3A%5C%22%E5%AE%8B%E4%BD%93%5C%22%2C%5C<span style="color: #009933; font-weight: bold;">%22s</span>ize%5C%22%3A%5C%2210%5C%22%2C%5C<span style="color: #009933; font-weight: bold;">%22s</span>tyle%5C%22%3A%5B0%2C0%2C0%5D%2C%5C<span style="color: #009933; font-weight: bold;">%22c</span>olor%5C%22%3A%5C%22000000%5C%22%7D%5D%5D%22%2C%22msg_id%22%3A<span style="color: #006699; font-weight: bold;">{$msg_id}</span>%2C<span style="color: #009933; font-weight: bold;">%22c</span>lientid%22%3A%22<span style="color: #006699; font-weight: bold;">{$clientid}</span>%22%2C%22psessionid%22%3A%22<span style="color: #006699; font-weight: bold;">{$psessionid}</span>%22%7D&clientid=<span style="color: #006699; font-weight: bold;">{$clientid}</span>&psessionid=<span style="color: #006699; font-weight: bold;">{$psessionid}</span>"</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"http://d.web2.qq.com/channel/send_buddy_msg2"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 必须要来路域名</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_REFERER<span style="color: #339933;">,</span> <span style="color: #0000ff;">"http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> <span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// curl_setopt($ch, CURLOPT_HEADER, TRUE);</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
6.发送QQ群消息
POST地址:http://d.web2.qq.com/channel/send_qun_msg2
POST值(请把参数值用urlencode函数编码)如下:
r={“group_uin”:{$group_id},”content”:”[\”{$msg}\\n\”,[\”font\”,{\”name\”:\”宋体\”,\”size\”:\”10\”,\”style\”:[0,0,0],\”color\”:\”000000\”}]]”,”msg_id”:{$msg_id},”clientid”:”{$clientid}”,”psessionid”:”{$psessionid}”}&clientid={$clientid}&psessionid={$psessionid}
部分参数解释:
group_uin:群的uin(非QQ群号)
content:发送的消息内容
psessionid:在第二次登录返回的JSON信息里边能找到
clientid:与第二次登录时候的clientid相同
附PHP版发送QQ群消息函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #009933; font-style: italic;">/** * 发送群消息 * * @access public * @param int $group_id * @param string $msg * @param string $psessionid * @param int $clientid * @return string */</span> <span style="color: #000000; font-weight: bold;">function</span> send_qun_msg<span style="color: #009900;">(</span><span style="color: #000088;">$group_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$psessionid</span><span style="color: #339933;">,</span> <span style="color: #000088;">$clientid</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> static <span style="color: #000088;">$msg_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">77860003</span><span style="color: #339933;">;</span> <span style="color: #000088;">$msg_id</span><span style="color: #339933;">++;</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"r=%7B%22group_uin%22%3A<span style="color: #006699; font-weight: bold;">{$group_id}</span>%2C<span style="color: #009933; font-weight: bold;">%22c</span>ontent%22%3A%22%5B%5C%22<span style="color: #006699; font-weight: bold;">{$msg}</span>%5C%5Cn%5C%22%2C%5B%5C<span style="color: #009933; font-weight: bold;">%22f</span>ont%5C%22%2C%7B%5C%22name%5C%22%3A%5C%22%E5%AE%8B%E4%BD%93%5C%22%2C%5C<span style="color: #009933; font-weight: bold;">%22s</span>ize%5C%22%3A%5C%2210%5C%22%2C%5C<span style="color: #009933; font-weight: bold;">%22s</span>tyle%5C%22%3A%5B0%2C0%2C0%5D%2C%5C<span style="color: #009933; font-weight: bold;">%22c</span>olor%5C%22%3A%5C%22000000%5C%22%7D%5D%5D%22%2C%22msg_id%22%3A<span style="color: #006699; font-weight: bold;">{$msg_id}</span>%2C<span style="color: #009933; font-weight: bold;">%22c</span>lientid%22%3A%22<span style="color: #006699; font-weight: bold;">{$clientid}</span>%22%2C%22psessionid%22%3A%22<span style="color: #006699; font-weight: bold;">{$psessionid}</span>%22%7D&clientid=<span style="color: #006699; font-weight: bold;">{$clientid}</span>&psessionid=<span style="color: #006699; font-weight: bold;">{$psessionid}</span>"</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"http://d.web2.qq.com/channel/send_qun_msg2"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_REFERER<span style="color: #339933;">,</span> <span style="color: #0000ff;">"http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_COOKIEFILE<span style="color: #339933;">,</span> <span style="color: #0000ff;">"cookie"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// curl_setopt($ch, CURLOPT_HEADER, TRUE);</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">(</span><span style="color: #000088;">$ch</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #666666; font-style: italic;">/* WebQQ3.0 core part end of */</span> |
|
事实上,做到心跳包的时候,再往下已经没有技术含量了,已经属于体力活了。
最后附一个基于WebQQ3.0写的一个开源的WebQQ机器人,有兴趣的朋友可以研究研究。
参考资料
http://www.cnblogs.com/gitdnn/archive/2013/01/13/2858408.html
http://www.meesii.in/71.html