• 追加された行はこの色です。
  • 削除された行はこの色です。
*SellerListingLookupのサンプルコード(C#) [#h97b017b]

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

Amazon以外の出品者が出品している商品の情報を表示するサンプルです。TextBoxに出品者のIDと商品のExchangeIDを入力します。

#code(csharp){{
<%@ Page Language="C#" %>
<%@ 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 void Button1_Click(object sender, EventArgs e)
    {
        SellerListingLookupRequest req = new SellerListingLookupRequest();
        //Seller IDを指定する
        req.SellerId = TextBox1.Text;
        //商品のID
        //req.IdType = SellerListingLookupRequestIdType.Exchange;
        req.Id = TextBox2.Text;

        SellerListingLookup sll = new SellerListingLookup();
        //あなたのAccess Key ID
        sll.AWSAccessKeyId = "(あなたのAccessKeyID)";
        //あなたのAssociate ID
        sll.AssociateTag = "dobonnet-22";
        sll.Request = new SellerListingLookupRequest[] { req };

        AWSECommerceService aws = new AWSECommerceService();
        SellerListingLookupResponse res;
        try
        {
            //SellerListingLookupオペレーションを実行し、結果を取得
            res = aws.SellerListingLookup(sll);
        }
        catch (Exception ex)
        {
            Label1.Text = "エラー:" + Server.HtmlEncode(ex.Message);
            return;
        }

        if (res == null || res.SellerListings == null)
        {
            Label1.Text = "結果を取得できませんでした。";
            return;
        }
        if (res.SellerListings[0].Request.Errors != null)
        {
            Label1.Text = "エラー:" +
                res.SellerListings[0].Request.Errors[0].Message;
            return;
        }
        if (res.SellerListings[0].SellerListing == null)
        {
            Label1.Text = "該当するSellerのリストが見つかりませんでした。";
            return;
        }

        //結果の表示
        Label1.Text = "";
        Label1.Text += "<ul>\n";
        foreach (SellerListing sl in res.SellerListings[0].SellerListing)
        {
            Label1.Text += "<li><b>" + sl.Title + "</b><br />\n";
            Label1.Text += "出品者 : " + sl.Seller.Nickname + "<br />\n";
            Label1.Text += "価格 : " + sl.Price.FormattedPrice + "<br />\n";
            Label1.Text += "コンディション : " + sl.Condition + "<br />\n";
            Label1.Text += "サブコンディション : " + sl.SubCondition +
                "<br />\n";
        }
        Label1.Text += "</ul>\n";
    }
</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>
        <br />
        <label for="TextBox2">ExchangeID : </label>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <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>
}}

//これより下は編集しないでください
#pageinfo(,2006-10-20 (金) 01:11:54,DOBON!,2006-10-20 (金) 01:11:54,DOBON!)
#pageinfo(,2006-10-20 (金) 01:11:54,DOBON!,2006-10-20 (金) 02:15:21,DOBON!)


[ トップ ]   [ 新規 | 子ページ作成 | 一覧 | 単語検索 | 最終更新 | ヘルプ ]