2017-10-10 29 views
-2

こんにちはGuysは、私はあなたの助けを必要とします。http上のJSONレスポンスを読み取ることVB.NETどのように私はこれがREPONSEにあるHTTPレスポンスにJSONを読みたい

{「レスポンス」:{「SESSION_ID」: "lku1ui1dr3ff4p2q4agmcd0jd3"、 "EXPIRE_DATE":1527950247、 "traffic_left": "1083573"}、 "response_status" 200、 "response_details":NULL}

これは、ポストデータの例示的なデータ

POST例であります/ api/user/login HTTP/1.1

受諾:/

ユーザエージェント:Mozilla/5.0(Windows; U; Windows NT 5.1;ヤモリのようなエン) のAppleWebKit/522.11.3(KHTML、)バージョン/ 3.0のSafari/522.11.3

ホスト:example.net

プラグマ:キャッシュなし

接続:キープアライブ

コンテンツタイプ:application/x-www-form-urlencodedでのContent-Length:=実施例46

名&パスワード= 1234456

私はそれが存在する場合、それは文字列

Public Sub method_5() 
     Dim proxyAddress As String = Me.string_1(Me.random_0.[Next](0, Me.int_1)), 
     While Me.queue_0.Count > 0 
      Dim obj As Object = Me.object_0 
      Dim flag As Boolean = False 
      Dim obj2 As Object 
      Dim text As String 
      Try 
       Dim expr_29 As Object = obj 
       obj2 = expr_29 
       Monitor.Enter(expr_29, flag) 
       Try 
        text = Me.queue_0.Peek().ToString().TrimEnd(New Char() {vbCr}).Trim() 
        Me.queue_0.Dequeue() 
       Catch ex As Exception 

       End Try 

      Finally 
       If flag Then 
#Disable Warning BC42104 ' Variable is used before it has been assigned a value 
        Monitor.[Exit](obj2) 
#Enable Warning BC42104 ' Variable is used before it has been assigned a value 
       End If 
      End Try 
      Dim array As String() = text.Split(New Char() {":"}) 
      Try 
       Using httpRequest As HttpRequest = New HttpRequest() 
        httpRequest.Proxy = ProxyClient.Parse(Me.proxyType_0, proxyAddress) 
        Dim cookies As CookieDictionary = New CookieDictionary(False) 
        httpRequest.Cookies = cookies 
        httpRequest.IgnoreProtocolErrors = True 
        httpRequest.ConnectTimeout = 25000 
        httpRequest.AllowAutoRedirect = True 
        httpRequest.KeepAlive = True 
        httpRequest.UserAgent = Http.ChromeUserAgent() 
        httpRequest.AddParam("username", array(0)) 
        httpRequest.AddParam("password", array(1)) 
        Dim text2 As String = httpRequest.Post("<website>").ToString() 
        If text2.Contains("") Then 
        End If 
        obj = Me.object_0 
        Dim flag2 As Boolean = False 
        Try 
         Dim expr_222 As Object = obj 
         obj2 = expr_222 
         Monitor.Enter(expr_222, flag2) 
#Disable Warning BC42025 ' Access of shared member, constant member, enum member or nested type through an instance 
         array.Resize(Of String)(Me.string_2, Me.int_2 + 1) 
#Enable Warning BC42025 ' Access of shared member, constant member, enum member or nested type through an instance 
#Disable Warning BC42104 ' Variable is used before it has been assigned a value 
          Me.string_2(Me.int_2) = +text + "|Subscription: " 
#Enable Warning BC42104 ' Variable is used before it has been assigned a value 
          Me.int_2 += 1 
         Me.int_5 += 1 
         Me.int_6 -= 1 
         Continue While 
        Finally 
         If flag2 Then 
          Monitor.[Exit](obj2) 
         End If 
        End Try 
        obj = Me.object_0 
        Dim flag3 As Boolean = False 
        Try 
         Dim expr_29E As Object = obj 
         obj2 = expr_29E 
         Monitor.Enter(expr_29E, flag3) 
         Me.int_3 += 1 
        Finally 
         If flag3 Then 
          Monitor.[Exit](obj2) 
         End If 
        End Try 
        Me.int_5 += 1 
        Me.int_6 -= 1 
       End Using 
      Catch 
       Me.int_7 += 1 
       Me.queue_0.Enqueue(text) 
       proxyAddress = Me.string_1(Me.random_0.[Next](0, Me.int_1)) 
      End Try 
     End While 
     If Me.int_5 = Me.int_0 Then 
      Me.method_6() 
     End If 
    End Sub 

として 薄暗いEXPIREDATEだけで、エラーがない完全なコードのその部分を引き起こし、あまりにも気にしない気にしないだろう、"expire_date":を読みたいですそれ

+0

はhttps://www.newtonsoft.com/jsonを見てみましょう。 – CiccioRocca

+0

[jsonを解析してvb.netで読み込む方法]の可能な複製(https://stackoverflow.com/questions/38943260/how-to-parse-json-and-read-in-vb-net) – CiccioRocca

+0

hmm let私は見て – Armangido

答えて

0

私は、これはあなたが探しているものに似ていると信じて:

Dim req As HttpWebRequest = WebRequest.Create("www.SomeURL.com/?username=somevalue&password=somevalue") 
Dim resp As HttpWebResponse = req.GetResponse() 

Dim enc As Encoding = System.Text.Encoding.GetEncoding(1252) 
Dim loResponseStream As StreamReader = New StreamReader(resp.GetResponseStream(), enc) 
Dim Response As String = loResponseStream.ReadToEnd() 
Dim jss As JavaScriptSerializer = New JavaScriptSerializer() 
Dim dict As Object = jss.Deserialize(Of Dictionary(Of String, Object))(Response) 
Dim expiredate As String = (dict("session_id")("expire_date")) 'You may need to play with this to get the value, wrote this off the top of my head ... 
loResponseStream.Close() 
+0

これを修正する方法[リンク](http://prntscr.com/gvq83a) – Armangido

+0

私はこのためにxNetを使っています – Armangido

+0

投稿を忘れました。 text2はレスポンスではなく、投稿です。 URLとユーザー名とパスワードのパラメータを使用してHttpWebRequestを作成すると、応答が得られます。次のようなリクエストを作成します。 'Dim req As HttpWebRequest = WebRequest.Create(" http://rapidgator.net/api/user/login/?username=& "&array(0)&" password = "&array( 1)) ' –

関連する問題