獲取接口數據

Public Function getProxyL(ByVal num As Integer, ByVal classid As Integer) As String

Dim rs As String = ""
Dim Expires_in As Integer = 0 '過期時間
Dim url As String = "http://域名/api/default?mid=20&num=" & num & "&classid=" & classid
Try
Dim objHTTP As Object = System.Web.HttpContext.Current.Server.CreateObject("Msxml2.ServerXMLHTTP")
objHTTP.open("GET", url, False)
objHTTP.send()
Dim r As String = objHTTP.responseText
objHTTP = Nothing
rs = r
Catch ex As Exception
Throw ex
End Try

Return rs
End Function

 

 

調用:

Dim Jsonstr As String = getProxyL(8, 27)
Dim r As ArrayList = CType(JsonConvert.DeserializeObject(Jsonstr, GetType(ArrayList)), ArrayList)
If r.Count > 0 Then
rpt_news.DataSource = r
rpt_news.DataBind()
End If

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章