0

我试图对我的程序使用 GET 方法而不是 POST 方法,这必然取决于 HTTPWEBREQUEST .. 这是我使用的代码

    Dim postData As String = "GET /fbml/ajax/dialog/apprequests?message=Here%27s%20a%20Anvil%20for%20your%20pet%20in%20Wild%20Ones!%20Could%20you%20help%20me%20by%20sending%20a%20gift%20back%3F&data=[%7B%22request_type%22%3A%22gift_v2%22%2C%20%22gift%22%3A%22anvil%22%7D%2C%7B%22track%22%3A%22invite-Gift-request2-anvil-20120112-0%22%7D]&to=[%22100003034461289%22]&e2e=%7B%7D&app_id=101628414658&locale=en_US&sdk=joey&display=async&frictionless=true&redirect_uri=https%3A%2F%2Fwild-fb-apache-active-vip.playdom.com%2Fpub%2Fphp%2F&__d=1&__user=1668282525&__a=1&__dyn=7n8ahyj3419Aw&__req=3 HTTP/1.1"
    Dim tempCookies As New CookieContainer
    Dim encoding As New UTF8Encoding
    Dim byteData As Byte() = encoding.GetBytes(postData)

    Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://apps.facebook.com/fbml/ajax/dialog/apprequests?message=Here%27s%20a%20Anvil%20for%20your%20pet%20in%20Wild%20Ones!%20Could%20you%20help%20me%20by%20sending%20a%20gift%20back%3F&data=[%7B%22request_type%22%3A%22gift_v2%22%2C%20%22gift%22%3A%22anvil%22%7D%2C%7B%22track%22%3A%22invite-Gift-request2-anvil-20120112-0%22%7D]&to=[%22100003034461289%22]&e2e=%7B%7D&app_id=101628414658&locale=en_US&sdk=joey&display=async&frictionless=true&redirect_uri=https%3A%2F%2Fwild-fb-apache-active-vip.playdom.com%2Fpub%2Fphp%2F&__d=1&__user=1668282525&__a=1&__dyn=7n8ahyj3419Aw&__req=3"), HttpWebRequest)
    postReq.Method = "GET"
    postReq.KeepAlive = True
    postReq.CookieContainer = tempCookies
    postReq.ContentType = "application/x-javascript; charset=utf-8"
    postReq.Referer = "https://apps.facebook.com/fbml/ajax/dialog/apprequests?message=Here%27s%20a%20Anvil%20for%20your%20pet%20in%20Wild%20Ones!%20Could%20you%20help%20me%20by%20sending%20a%20gift%20back%3F&data=[%7B%22request_type%22%3A%22gift_v2%22%2C%20%22gift%22%3A%22anvil%22%7D%2C%7B%22track%22%3A%22invite-Gift-request2-anvil-20120112-0%22%7D]&to=[%22100003034461289%22]&e2e=%7B%7D&app_id=101628414658&locale=en_US&sdk=joey&display=async&frictionless=true&redirect_uri=https%3A%2F%2Fwild-fb-apache-active-vip.playdom.com%2Fpub%2Fphp%2F&__d=1&__user=1668282525&__a=1&__dyn=7n8ahyj3419Aw&__req=3"
    postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
    postReq.ContentLength = byteData.Length
    Dim postreqstream As Stream = postReq.GetRequestStream()
    postreqstream.Write(byteData, 0, byteData.Length)
    postreqstream.Close()
    Dim postresponse As HttpWebResponse

    postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
    tempCookies.Add(postresponse.Cookies)
    logincookie = tempCookies
    Dim postreqreader As New StreamReader(postresponse.GetResponseStream())

    Dim thepage As String = postreqreader.ReadToEnd
    WebBrowser1.DocumentText = thepage
4

1 回答 1

1

您可以使用网络客户端

Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("url here")

此外,您在代码中使用的 URL 看起来不完整

于 2013-07-17T09:44:25.783 回答