SellerListingSearchのサンプルコード(VB.NET)

ここで紹介しているコードはこちらのプロキシクラスを使用しています。

ここで紹介しているコードはこちらのC#のコードをVB.NETに変換したものです。

指定した出品者が出品している商品を表示するサンプルです。TextBoxに出品者のIDを入力します。

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
<%@ Page Language="VB" %>
<%@ Import Namespace="Amazon.jp.v20060913" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<script runat="server">
 
    Protected Sub Button1_Click(ByVal sender As Object, _
        ByVal e As EventArgs)
        Dim req As New SellerListingSearchRequest()
        'Seller IDを指定する
        req.SellerId = TextBox1.Text
        'タイトル名で並べる
        req.Sort = "title"
   
        Dim sls As New SellerListingSearch()
        'あなたのAccess Key ID
        sls.AWSAccessKeyId = "(あなたのAccessKeyID)"
        'あなたのAssociate ID
        sls.AssociateTag = "dobonnet-22"
        sls.Request = New SellerListingSearchRequest() {req}
   
        Dim aws As New AWSECommerceService()
        Dim res As SellerListingSearchResponse
        Try
            'SellerListingSearchオペレーションを実行し、結果を取得
            res = aws.SellerListingSearch(sls)
        Catch ex As Exception
            Label1.Text = "エラー:" + Server.HtmlEncode(ex.Message)
            Return
        End Try
   
        If res Is Nothing OrElse res.SellerListings Is Nothing Then
            Label1.Text = "結果を取得できませんでした。"
            Return
        End If
        If Not (res.SellerListings(0).Request.Errors Is Nothing) Then
            Label1.Text = "エラー:" + _
                res.SellerListings(0).Request.Errors(0).Message
            Return
        End If
        If res.SellerListings(0).SellerListing Is Nothing Then
            Label1.Text = "該当するSellerのリストが見つかりませんでした。"
            Return
        End If
   
        '結果を表示
        Dim listings As SellerListings = res.SellerListings(0)
        Label1.Text += "総数 : " + listings.TotalResults + "<br />"
        Label1.Text += "<ul>" + vbLf
        Dim sl As SellerListing
        For Each sl In listings.SellerListing
            Label1.Text += "<li><b>" + sl.Title + "</b><br />" + vbLf
            Label1.Text += "価格 : " + sl.Price.FormattedPrice + _
                "<br />" + vbLf
            Label1.Text += "ExchangeID : " + sl.ExchangeId + _
                "<br />" + vbLf
            Label1.Text += "ASIN : " + sl.ASIN + "<br />" + vbLf
            Label1.Text += "ListingId : " + sl.ListingId + _
                "<br />" + vbLf
        Next sl
        Label1.Text += "</ul>" + vbLf
    End Sub
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Amazon出品者の商品リスト表示</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <label for="TextBox1">出品者のID : </label>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server"
         OnClick="Button1_Click" Text="送信" /><br />
    </div>
    </form>
    <br />
    <asp:Label ID="Label1" runat="server" EnableViewState="False">
    </asp:Label>
</body>
</html>

ページ情報
  • 作成日 : 2006-10-20 (金) 00:59:49
  • 作成者 : DOBON!
  • 最終編集日 : 2006-10-20 (金) 02:19:47
  • 最終編集者 : DOBON!
[ トップ ]   [ 新規 | 子ページ作成 | 一覧 | 単語検索 | 最終更新 | ヘルプ ]