2

我一直在设计一个程序,帮助用户浏览和使用在线约会网站。该程序的一部分允许用户通过该程序发送消息,但我在使用 pof.com 网站时遇到了问题。

我已经验证了 postData 变量生成的字符串与我的浏览器发送的字符串完全匹配。这是我认为问题所在的代码:

    pofMessage = HttpUtility.UrlEncode(pofMessage)
    Dim postData As String = sendParameter1 & "=" & sendParameter1_Value & "&autologinid=" & autoLoginID & "&message_id=" & messageID & "&u=" & u & "&p_id=" & p_ID & "&receiver=" & receiver & "&profile_idb=" & profile_idb & "&usersendtob=" & usersendtob & "&i=" & i & "&v=" & v & "&subject=" & pofSubject & "&message=" & pofMessage & "&sendmessage=Send+Quick+Msg"
    Dim encoding As New UTF8Encoding
    Dim bytedata As Byte() = encoding.GetBytes(postData)
    'postData = "7512b8a8=b5818092d0d1d696329a2f6a8e9ef5b7&autologinid=vfnbrfzx4cptyhoimlojxs54&message_id=&u=Ca_Polo&p_id=40749839&reciever=janebrandy2000&profile_idb=40749839&usersendtob=44672906&i=18213689&v=13&subject=Hi&message=sorry...I+meant+my+great+grandmother.++She+was+a+very+sweet+person.&sendmessage=Send+Quick+Msg"

    Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://www.pof.com/sendmessage.aspx"), HttpWebRequest)
    postReq.Method = "POST"
    postReq.KeepAlive = True
    postReq.CookieContainer = loginCookie
    postReq.ContentType = "application/x-www-form-urlencoded"
    postReq.Referer = "http://www.pof.com/viewprofile.aspx?profile_id=" & profileAddressSend(arrayIndex)
    postReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0"
    postReq.ContentLength = bytedata.Length
    MessageBox.Show(postData)
    Dim postReqStream As Stream = postReq.GetRequestStream()
    postReqStream.Write(bytedata, 0, bytedata.Length)

我不知道这是否有用,但这是实时 HTTP 标头给我的:

--------------BEGIN HEADERS---------------------------

http://www.pof.com/sendmessage.aspx

POST /sendmessage.aspx HTTP/1.1
Host: www.pof.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Referer: http://www.pof.com/viewprofile.aspx?profile_id=40749839
Cookie: ft=Friday, May 04, 2012 10:56:08 PM; __utma=181982502.1869691959.1336197311.1339544889.1339562544.21; __utmz=181982502.1338435116.11.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); usernameb=my_username; tmp_track=18213689; __utmv=181982502.|2=intent=want%20to%20date%20but%20nothing%20serious=1^3=age=35=1^4=Gender=Male%20United%20States=1; __gads=ID=b617d731de96c1fd:T=1336199229:S=ALNI_MaTMf9mj4CcziGfucCbsyfH-o2CdA; tbtext002=Dating%2CA; t_user_id=18213689; ASP.NET_SessionId=vfnbrfzx4cptyhoimlojxs54; __utmc=181982502; POFIMSession=634751342250621962; __utmb=181982502.4.10.1339562544; alogin=vfnbrfzx4cptyhoimlojxs54; mp_60ea1aa63a18cdb7ab1fb007106b9de3_mixpanel=%7B%22distinct_id%22%3A%20%22137d031c4821a4-050684bdf5e497-43534134-100200-137d031c4837d%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D
Content-Type: application/x-www-form-urlencoded
Content-Length: 308
7512b8a8=b5818092d0d1d696329a2f6a8e9ef5b7&autologinid=vfnbrfzx4cptyhoimlojxs54&message_id=&u=my_username&p_id=40749839&reciever=janebrandy2000&profile_idb=40749839&usersendtob=44672906&i=18213689&v=13&subject=Hi&message=this+is+a+sample+message&sendmessage=Send+Quick+Msg
HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: /inbox.aspx?messagesent=1&p_id=40749839&Guid=18213689&SID=vfnbrfzx4cptyhoimlojxs54#in
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 13 Jun 2012 04:44:32 GMT
Content-Length: 214

-----------------------END HEADERS---------------------

这是我已经验证的(我认为......除非我遗漏了什么):postData 是准确的。我使用的 cookie 用于浏览网站(即,如果我想查看我的收件箱,cookie 将允许我这样做。如果 cookie 不起作用,我无法查看我的收件箱)。

我在这里想念什么?

4

0 回答 0