SellerLookupのサンプルコード(C#)

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

Amazon.co.jpの出品者へのカスタマーからの評価やフィードバックを表示するサンプルです。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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<%@ 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)
    {
        SellerLookupRequest req = new SellerLookupRequest();
        //出品者のIDを指定
        req.SellerId = new string[] { TextBox1.Text };
 
        SellerLookup sl = new SellerLookup();
        //あなたのAccess Key ID
        sl.AWSAccessKeyId = "(あなたのAccessKeyID)";
        //あなたのAssociate ID
        sl.AssociateTag = "dobonnet-22";
        sl.Request = new SellerLookupRequest[] { req };
 
        AWSECommerceService aws = new AWSECommerceService();
        SellerLookupResponse res;
        try
        {
            //SellerLookupオペレーションを実行し、結果を取得
            res = aws.SellerLookup(sl);
        }
        catch (Exception ex)
        {
            Label1.Text = "エラー:" + Server.HtmlEncode(ex.Message);
            return;
        }
 
        if (res == null || res.Sellers == null)
        {
            Label1.Text = "結果を取得できませんでした。";
            return;
        }
        if (res.Sellers[0].Request.Errors != null)
        {
            Label1.Text = "エラー:" +
                res.Sellers[0].Request.Errors[0].Message;
            return;
        }
        if (res.Sellers[0].Seller == null)
        {
            Label1.Text = "該当するSellerが見つかりませんでした。";
            return;
        }
 
        //結果を表示
        Label1.Text = "";
        Label1.Text += "<ul>\n";
        foreach (Seller s in res.Sellers[0].Seller)
        {
            Label1.Text += "<li><b><a href=\"" +
                s.GlancePage + "\">" + s.Nickname + "</a></b>\n";
            if (s.AverageFeedbackRatingSpecified)
                Label1.Text += "<br />過去1年間の評価 : " +
                    s.AverageFeedbackRating.ToString();
            Label1.Text += "<br />Seller Id : " + s.SellerId;
 
            Label1.Text += "<br />評価数:" + s.TotalFeedback;
            Label1.Text += "<br />評価ページ数:" + s.TotalFeedbackPages;
            //評価の表示
            Label1.Text += "<br />最近の評価:" + s.TotalFeedbackPages;
            if (s.SellerFeedback != null)
            {
                Label1.Text += "<ul>\n";
                foreach (SellerFeedbackFeedback fb in s.SellerFeedback)
                {
                    Label1.Text += "<li>評価 : " + fb.Rating;
                    Label1.Text += "<br />コメント : " + fb.Comment;
                    Label1.Text += "<br />評価した購入者のID : " + fb.RatedBy;
                    Label1.Text += "<br />日付 : " + fb.Date;
                }
                Label1.Text += "</ul>\n";
            }
 
            //評価のサマリーの表示
            Label1.Text += "<br />評価のサマリー:" + s.TotalFeedbackPages;
            if (s.SellerFeedback != null)
            {
                Label1.Text += "<ul>\n";
                foreach (SellerFeedbackDateRange fb in s.SellerFeedbackSummary)
                {
                    Label1.Text += "<li>評価期間 : " + fb.Period;
                    Label1.Text += "<ul>\n";
                    foreach (SellerFeedbackDateRangeSellerFeedbackRating r
                        in fb.SellerFeedbackRating)
                    {
                        Label1.Text += "<li>評価 : " + r.Type;
                        Label1.Text += "<br />評価数 : " + r.Count;
                        Label1.Text += "<br />割合 : " + r.Percentage + "%";
                    }
                    Label1.Text += "</ul>\n";
                }
                Label1.Text += "</ul>\n";
            }
        }
        Label1.Text += "</ul>\n";
 
    }
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head 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:55:30
  • 作成者 : DOBON!
  • 最終編集日 : 2006-10-20 (金) 02:15:48
  • 最終編集者 : DOBON!
[ トップ ]   [ 新規 | 子ページ作成 | 一覧 | 単語検索 | 最終更新 | ヘルプ ]