1
我正在使用asp vb.net和instagram api。錯誤在Instagram API中
我在instagram api上找到了tutorial,但它在c#中。我試圖從c#轉換到VB最好的,但我出於某種原因,我得到一個錯誤。
Dim result = client.UploadValues("https://api.instagram.com/oauth/access_token", "POST", parameters)
我的代碼:
Function GetDataInstagramToken()
Try
Dim parameters As New NameValueCollection
parameters.Add("client_id", Client_ID)
parameters.Add("client_secret", ClientSecret)
parameters.Add("grant_type", "authorization_code")
parameters.Add("redirect_uri", "http://localhost:8979/UI/InstaHome.aspx")
parameters.Add("code", Code)
Dim client As WebClient = New WebClient()
Dim result = client.UploadValues("https://api.instagram.com/oauth/access_token", "POST", parameters)
Dim response = System.Text.Encoding.Default.GetString(result)
'deserializing nested JSON string to object
Dim jsResult As JObject = JsonConvert.DeserializeObject(response)
Dim accessToken As String = jsResult("access_token")
Dim id As Int16 = jsResult("user")("id")
'This code register id and access token to get on client side
Page.ClientScript.RegisterStartupScript(GetType(String()), "GetToken", "<script>var instagramaccessid=\"" + @"" + id + "" + " \ "; var instagramaccesstoken=\"" + @"" + accessToken + "" + " \ ";</script>")
Catch ex As Exception
myLabel.text += "-" &ex.message
End Try
End Function
檢查我的答案我用它,它應該工作 –