2013-05-29 3 views
0

я пытался использовать метод GET вместо метода POST для моей программы, которая обязательно зависит от HttpWebRequest .. здесь код я использовалVb.net HTTPWEBREQUESTS GET метод

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 
+0

И вопрос? Разве это не работает? Это ошибка? – Tim

+0

NOOOO ЭТО НЕ РАБОТАЕТ, ПОЧЕМУ Я ПОЛУЧИЛ КОДЕКС ЗДЕСЬ, ПОТОМУ ЧТО ЧТО-ТО НУЖНО С КОДОМ –

+0

Не работает ** как **? Это не работает? Это не делает то, что вы ожидали от этого? Выбрасывает исключение? Вы пробовали переходить через код с помощью отладчика? И, пожалуйста, не используйте все кепки - это интернет-эквивалент крика и считается грубым. – Tim

ответ

0

Вы можете использовать служба веб

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

Также URL вы использовали в своем коде выглядит неполным