First, the disclaimer, I'm doing all this in ASP.NET 2.0 with VS 2005. If you're using plain old ASP, or VS 2003, it may or may not work.
To begin, you'll need to add an IMG tag somewhere on your page (or, in the case of dasBlog, somewhere in the homeTemplate.blogtemplate file that's part of the theme you wish to use. Note: If you allow users to change the theme in dasBlog, then you'll need to add this IMG tag to all themes you'd like it to be part of. For this blog, I disabled the switching of themes, so I only had to add this tag to one file.
<img src="./themes/[your theme name]/IMStatusImageProxy.aspx?type=ICQ" title="Tooltip your want to display" >
Where [your theme name] is just that. This just allows you to put the IMStatusImageProxy.aspx file in your theme path. If you prefer, you could copy it to the dasBlog root path and just reference it there.
This tag causes the browser to go and load the IMStatusImageProxy.aspx page for the image to use when it needs to obtain the image for the IMG tag. Now, that ASPX page isn't actually an image at all, but the browser doesn't care at this point.
Next, create the IMStatusImageProxy.ASPX page. You'll need to put it in your theme's folder (or in the dasBlog root as I mentioned above).
<%@ Page Language="VB" %> <script runat="server"> ' ------------------------------------------------------------------------------------------ ' IMStatusImageProxy.asp ' ' Used to retrieve the content of the status image from ' websites that serve them up. ' I don't believe there's a way to avoid the proxy page ' when pulling the images. At least not and remain easily compatible with ' dasBlog. ' The original idea is from Dino Esposito. ' ------------------------------------------------------------------------------------------ Private Function pGetWebPageImage(ByVal URL As String) As Byte() '---- Create the HttpWebRequest object Dim req As System.Net.HttpWebRequest = System.Net.WebRequest.Create(URL) Dim Results As Byte() Try '---- Get the data as an HttpWebResponse object Dim resp As System.Net.HttpWebResponse = req.GetResponse() '---- Convert the data into a string (assumes that you are requesting text) Dim br As New System.IO.BinaryReader(resp.GetResponseStream()) Results = br.ReadBytes(50000) br.Close() Catch ex As System.Net.WebException 'Something went awry in the HTTP request! ReDim Results(0) End Try Return Results End Function Public Sub Page_Load() '---- Retrieve the TYPE of IM system whose status ' is being requested Dim IMType As String = Ucase(Request.QueryString("type")) Dim ImgType as String = "image/gif" Dim r() as Byte '---- set up the response object Response.Expires = 0 Response.Buffer = True Response.Clear() '---- Filter for the good arg values ' we don't want to allow just any old parm value in Select Case IMType Case "ICQ" '---- handle ICQ status ' ICQ makes this relatively easy because they have a service to ' retrieve that info ' Retrieves a GIF type image r = pGetWebPageImage("http://status.icq.com/online.gif?icq=[YOURICQNUM]&img=16") 'Case "AIM" '---- handle AIM status here 'Case "HOTMAIL" '---- handle AIM status here Case Else '---- not a valid IM type so bail out Response.End() Exit sub End Select '---- set the image info saved from the main page ' into the response object Response.ContentType = ImgType Response.BinaryWrite(r) '---- since this is a proxy, end the response now Response.End() End Sub </script>
You'll obviously want to replace [YOURICQNUM] with you're own ICQ number. However, since your ICQ number is in the code portion of the ASPX page, it won't be visible in any way to the web browser, and hence, the public.
Also, the &img=16 is a parameter that indicates to the ICQ webservice which imageset you'd like to use. You might want to experiment with different numbers, from 1 on up. 16 looked pretty good to me.
Essentially, the idea of this proxy page is to:
I thought this approach was quite nice for several reasons
Let me know what you think!
Remember Me
a@href@title, b, i, strike, strong
Page rendered at Saturday, July 31, 2010 6:51:07 AM (Central Standard Time, UTC-06:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.