Home >Web Front-end >JS Tutorial >Automatically obtain QQ personal avatar and online status through MSXML2 (for beginners)_javascript skills

Automatically obtain QQ personal avatar and online status through MSXML2 (for beginners)_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:20:281440browse

I don’t know if you are very familiar with MSXML2. It obtains a QQ number's avatar and online status from the Tencent website (I can't help it even if the person is invisible). Of course, you can also obtain the QQ nickname, location, etc. The specific implementation method is as follows:
First create two functions, use To process a URL

Copy code The code is as follows:
<%
function getHTTPPage (url)
dim http
set http=createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate< ;>4 then >end function
''''''''The following characters are processed
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i 1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 CInt(NextCharCode))
i = i 1
End If
Next
bytes2BSTR = strReturn
End Function
%>

You can collect these two functions, they are extremely useful.
You can take a look at this address http: //friend.qq.com/cgi-bin/friend/oicq_find?oicq_no=5292816
(QQ belongs to me, I am very busy every day, please be aware, hehe, discussion of issues is very welcome)
The following we Get information through Tencent’s friend search,



Copy code


The code is as follows:
< % function qqhead(qq) url="http://friend.qq.com/cgi-bin/friend/oicq_find?oicq_no="&qq content=getHTTPPage(url) if len(content)>6360 then 'If QQ is invalid, do some processing to avoid errors.
content=replace(mid(content,instr(content,"http://img.tencent.com"),38 ),"""","")
qqhead=""
else
qqhead=""
end if
end function

'OK, you're done. Now everyone just needs to call it.
response.write qqhead(5292816)
If the QQ avatar is in color, it means that the friend is online. The gray one means it is not online.
%>

You can go to http://www.okwest.net/books to see the effect. Haha.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn