Through MSXML2 automatic access to QQ personal avatar and online situation (for beginners) _ Application Skills

Source: Internet
Author: User
Tags chr
I do not know if you are familiar with the msxml2.xmlhttp, but its function can be said to have reached the pole. You can through it to the other people's website "moved back", hehe, bragging!!
Today I use it from the Tencent website to get a QQ number of the head, online situation (I have no way to be invisible). Of course, we can also get QQ nickname, location, etc. the implementation method is as follows:
First, two functions are created to handle a URL
Copy Code code as follows:

<%
function gethttppage (URL)
Dim http
Set Http=createobject ("MSXML2. XMLHTTP ")
Http.open "Get", Url,false
Http.send ()
If Http.readystate<>4 Then
Exit function
End If
Gethttppage=bytes2bstr (Http.responsebody)
Set http=nothing
If Err.number<>0 then err. Clear
End Function
"'" ' the following processing characters
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
%>
These two functions you can collect, very useful.
We can take a look at this address first http://friend.qq.com/cgi-bin/friend/oicq_find?oicq_no=5292816
(QQ is my, I am very busy every day, please everyone consciously, hehe, discuss the question very welcome)
Here we will get information through Tencent's Buddy lookup,
<%
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 not valid, do some processing to avoid error occurrence.
Content=replace (content,instr (content, "http://img.tencent.com"), 38, "" "," ")
qqhead= "<a href= ' http://friend.qq.com/cgi-bin/friend/user_show_info?ln=" &qq& "' target= ' _blank ' > </a> '
Else
Qqhead= ""
End If
End Function
' OK, it's done. Now all you have to do is call.
Response.Write Qqhead (5292816)
If the QQ avatar is colored, the explanation friend is online, the gray is not online.
%>

We can go to http://www.okwest.net/books to see the effect. hehe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.