我正在尝试做一个 Bing 图像搜索应用程序(Azure 版本),但我无法取得进展。代码语言是 vb.net。基本上我正在做的是尝试编辑这段代码,它确实有效。任何解决方案?
Function ExecuteQuery() As Boolean
Dim esito As Boolean = False
Try
Dim query As String = System.Web.HttpUtility.UrlEncode("Inception Movie")
Dim skip As String = "10"
Dim urlBase As New Uri("https://api.datamarket.azure.com")
Dim accountKey As String = "tymv8z6jFSdo4eQ3vsS5r8SZAmFtA24e6dmfyvaLh3U"
Dim credentials As New NetworkCredential(accountKey, accountKey)
Dim dsc As New System.Data.Services.Client.DataServiceContext(urlBase)
dsc.Credentials = New NetworkCredential(accountKey, accountKey)
Dim urlSearch As Uri = New Uri(("https://api.datamarket.azure.com/Bing/Search/Image?Query=%27" + query + "%27&$skip=" + skip))
Dim webResults = dsc.Execute(Of WebResult)(urlSearch)
For Each result As WebResult In webResults
ListBox1.Items.Add(result.Title)
ListBox1.Items.Add(result.Description)
singleValue = singleValue + 1
Next
esito = True
Catch ex As Exception
esito = False
End Try
Return esito
End Function
Partial Public Class WebResult
Private _ID As Guid
Private _Title As [String]
Private _Description As [String]
Private _DisplayUrl As [String]
Private _Url As [String]
Private _MediaUrl As [String]
Public Property ID() As Guid
Get
Return Me._ID
End Get
Set(ByVal value As Guid)
Me._ID = value
End Set
End Property
Public Property Title() As [String]
Get
Return Me._Title
End Get
Set(ByVal value As [String])
Me._Title = value
End Set
End Property
Public Property Description() As [String]
Get
Return Me._Description
End Get
Set(ByVal value As [String])
Me._Description = value
End Set
End Property
Public Property DisplayUrl() As [String]
Get
Return Me._DisplayUrl
End Get
Set(ByVal value As [String])
Me._DisplayUrl = value
End Set
End Property
Public Property Url() As [String]
Get
Return Me._Url
End Get
Set(ByVal value As [String])
Me._Url = value
End Set
End Property
Public Property MediaUrl() As [String]
Get
Return Me._MediaUrl
End Get
Set(ByVal value As [String])
Me._MediaUrl = value
End Set
End Property
End Class