0

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
4

1 に答える 1

0

私は今パズルを解いて、クラスファイルを使用するだけでこれを行う簡単な方法を確立しました:

1 - このファイルをダウンロードするだけです: http://www.getcodesamples.com/src/15958EA3/F43E1E1A 2 - 次に、同じファイルをプロジェクトに追加します 3 - 次のコードを追加します:

Dim strBingKey As String = "xxxaccountkeyxxx"
    Dim bingClass As New Bing.BingSearchContainer(New Uri("https://api.datamarket.azure.com/Bing/Search/"))
    bingClass.Credentials = New NetworkCredential(strBingKey, strBingKey)

    Dim query = bingClass.Image("Inception" + "Movie", Nothing, "en-us", "Off", Nothing, Nothing, Nothing)
    Dim results = query.Execute()
    For Each result In results
        ListBox1.Items.Add(result.Title)
        ListBox1.Items.Add(result.MediaUrl)
        Console.WriteLine(result.Thumbnail) 'ThumbNail type, need to convert to use in result list

    Next

お待ちいただきありがとうございます。

于 2013-11-12T18:32:24.913 に答える