My Blog on My Mobile Via WAP
By Jian Shuo Wang on 2003-03-20 23:21 · WAPThese days, I have setup the WAP site for Wangjianshuo’s Blog. I can get the latest comments on my web site and the total hit count from my mobile. I’d like to share the source code and steps with all blog users - especially for MovableType owners since you can convert your web site to WAP site with the code I provide.
How to access the WAP site
If you have a WAP-enabled mobile, please visit the following web site:
Here is the two images (left is the home page displaying all the comments and the right picture shows the hit counter)
The above are the simulated OT301 screen using UP.Simulator. I hope I can give you a picture of the page on my Alcatel OT715 one day.
Note: If you click the link above in Internet Explorer, you will not see the page. Instead, you are prompted to download the page, since it returns “text/vnd.wap.wml” as content type which cannot be proccessed by Internet Explorer.
The WAP page - WML file
If you save the page to your local disk and open it in notepad, you will see the following codes:
* Hits
After you click the *Hits link, you get the following WML code:
Page hits: 127502
[Back]
Code behind the sceen
I used an ASP file to do the job. You can easily convert it to Perl or PHP code. If you are using MovableType, follow the steps below to create a WAP index template.
Open MovableType console and open the blog you are editing.
Click “Templates” on the left navigation bar.
Click “Click new index template” in the Index Template section.
Enter “WAP Index” in Name field and “WAP/Index.asp” in the Output file field.
Use the code below in the Template body field.
Save the template and rebuild. You will have the WAP page at WAP/index.asp.
<%
'
’ Copyright 2003 Jian Shuo Wang
’ URL: http://wangjianshuo.com
’ Author: Jian Shuo Wang
’ Created: March 18, 2003
’ Description:
’ This page displays the latest comments
’ on any mobile phone supporting WAP.
'
%>
<%
Response.ContentType=“text/vnd.wap.wml”
If Request(“ID”) = "" Then
Response.Expires = -1
End If
%>
<%
'
’ The standard header every card need
'
%>
<%
Select Case Request(“ID”)
’ =================================
’ Comment content
’ =================================
%>
<%
Case “<$MTCommentID$>”:
%>
<$MTCommentBody$>
- by <$MTCommentEmail$> at <$MTCommentDate$> from <$MTCommentIP$>
[Back]
<%
Case “”:
’ =================================
’ Homepage - Comment Index
’ =================================
%>
* Hits
<%
Case Else:
%>
Something wrong with the page
<%
End Select
%>
Comments on the code
Response.ContentType=“text/vnd.wap.wml” must be included since it let the WAP browser understand it is a WML content since it cannot be judged from the .ASP extension.
It may need some modification before it can work on your site.
6 Comments
Thanks!
thankx.
*phfeew... It's been a while. So, what's been going on? GMAT's done, three more weeks before the deadline for my MBA application. Shoot, gotta get going on this... :-) Now that I've got some free time, my hands are itching...