0
你好,我有這行代碼我試圖分裂從HTTP readerGetResponse流得到令牌,長度不能小於零。參數名稱:長度在試圖分裂令牌
whle打破它顯示了這個錯誤代碼「長度不能小於零參數名:長度試圖分裂令牌」
Dim tokens As New Dictionary(Of String, String)()
Dim url As String = String.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", app_id, "http://localhost:28782/webform2.aspx", scope, Me.Request("code").ToString(), app_secret)
Dim request As HttpWebRequest = TryCast(WebRequest.Create(url), HttpWebRequest)
Using response As HttpWebResponse = TryCast(Request.GetResponse(), HttpWebResponse)
Dim reader As New StreamReader(response.GetResponseStream())
Dim vals As String = reader.ReadToEnd()
For Each token As String In vals.Split("&"c)
**tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1))**
Next
End Using
Dim access_token As String = tokens("access_token")
Context.Session("AccessToken") = access_token
Response.Redirect("http://localhost:28782/allproducts.aspx")
這裏我強調是哪裏出錯時。謝謝