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

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

ECSで使用できるオペレーションやResponseGroupの情報を表示するサンプルです。

  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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<%@ 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)
    {
        HelpRequest req = new HelpRequest();
        //何についてのHelpを取得するかを指定
        if (HelpTypeList.SelectedValue == "Operation")
            req.HelpType = HelpRequestHelpType.Operation;
        else if (HelpTypeList.SelectedValue == "ResponseGroup")
            req.HelpType = HelpRequestHelpType.ResponseGroup;
        req.HelpTypeSpecified = true;
        req.About = AboutList.SelectedValue;
        
        Help hlp = new Help();
        //あなたのAccess Key ID
        hlp.AWSAccessKeyId = "(あなたのAccessKeyID)";
        //あなたのAssociate ID
        hlp.AssociateTag = "dobonnet-22";
        hlp.Request = new HelpRequest[] { req };
 
        AWSECommerceService aws = new AWSECommerceService();
        HelpResponse res;
        try
        {
            //Helpオペレーションを実行し、結果を取得
            res = aws.Help(hlp);
        }
        catch (Exception ex)
        {
            Label1.Text = "エラー:" + ex.Message;
            return;
        }
 
        if (res == null || res.Information == null)
        {
            Label1.Text = "結果を取得できませんでした。";
            return;
        }
        if (res.Information[0].Request.Errors != null)
        {
            Label1.Text = "エラー:" +
                res.Information[0].Request.Errors[0].Message;
            return;
        }
 
        //結果を表示
        Label1.Text = "";
        Information info = res.Information[0];
        if (info.OperationInformation != null)
        {
            //OperationのHelp情報を表示
            Label1.Text = "<ul>\n";
            foreach (OperationInformation i in info.OperationInformation)
            {
                Label1.Text += "<li><strong>" + i.Name + "</strong>\n";
                Label1.Text += "<li>説明 : " + i.Description + "\n";
 
                Label1.Text += "<li>必須パラメーター :\n";
                Label1.Text += "<ul>\n";
                foreach (string s in i.RequiredParameters)
                {
                    Label1.Text += "<li>" + s + "\n";
                }
                Label1.Text += "</ul>\n";
                
                Label1.Text += "<li>オプションパラメーター :\n";
                Label1.Text += "<ul>\n";
                foreach (string s in i.AvailableParameters)
                {
                    Label1.Text += "<li>" + s + "\n";
                }
                Label1.Text += "</ul>\n";
 
                Label1.Text += "<li>デフォルトのResponseGroup :\n";
                Label1.Text += "<ul>\n";
                foreach (string s in i.DefaultResponseGroups)
                {
                    Label1.Text += "<li>" + s + "\n";
                }
                Label1.Text += "</ul>\n";
 
                Label1.Text += "<li>指定可能なResponseGroup :\n";
                Label1.Text += "<ul>\n";
                foreach (string s in i.AvailableResponseGroups)
                {
                    Label1.Text += "<li>" + s + "\n";
                }
                Label1.Text += "</ul>\n";
            }
            Label1.Text += "</ul>\n";
        }
        else if (info.ResponseGroupInformation != null)
        {
            //ResponseGroupのHelp情報を表示
            Label1.Text = "<ul>\n";
            foreach (ResponseGroupInformation i in
                info.ResponseGroupInformation)
            {
                Label1.Text += "<li><strong>" + i.Name + "</strong>\n";
                Label1.Text += "<li>作成日 : " + i.CreationDate + "\n";
 
                Label1.Text += "<li>Operation :\n";
                Label1.Text += "<ul>\n";
                foreach (string s in i.ValidOperations)
                {
                    Label1.Text += "<li>" + s + "\n";
                }
                Label1.Text += "</ul>\n";
 
                Label1.Text += "<li>Element :\n";
                Label1.Text += "<ul>\n";
                foreach (string s in i.Elements)
                {
                    Label1.Text += "<li>" + s + "\n";
                }
                Label1.Text += "</ul>\n";
            }
            Label1.Text += "</ul>\n";
        }
        else
        {
            Label1.Text += "表示する内容がありません。";
        }
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            SetAboutList();
    }
 
    protected void HelpTypeList_SelectedIndexChanged(
        object sender, EventArgs e)
    {
        SetAboutList();
    }
 
    protected void SetAboutList()
    {
        //Aboutに設定できる値をDropDownListに設定する
        AboutList.Items.Clear();
        if (HelpTypeList.SelectedValue == "Operation")
        {
            AboutList.Items.Add("CartAdd");
            AboutList.Items.Add("CartClear");
            AboutList.Items.Add("CartCreate");
            AboutList.Items.Add("CartModify");
            AboutList.Items.Add("CustomerContentLookup");
            AboutList.Items.Add("CustomerContentSearch");
            AboutList.Items.Add("Help");
            AboutList.Items.Add("ItemLookup");
            AboutList.Items.Add("ItemSearch");
            AboutList.Items.Add("ListLookup");
            AboutList.Items.Add("ListSearch");
            AboutList.Items.Add("SellerListingLookup");
            AboutList.Items.Add("SellerListingSearch");
            AboutList.Items.Add("SellerLookup");
            AboutList.Items.Add("SimilarityLookup");
            AboutList.Items.Add("TransactionLookup");
        }
        else if (HelpTypeList.SelectedValue == "ResponseGroup")
        {
            AboutList.Items.Add("Accessories");
            AboutList.Items.Add("BrowseNodes");
            AboutList.Items.Add("Cart");
            AboutList.Items.Add("CartSimilarities");
            AboutList.Items.Add("CustomerFull");
            AboutList.Items.Add("CustomerInfo");
            AboutList.Items.Add("CustomerLists");
            AboutList.Items.Add("CustomerReviews");
            AboutList.Items.Add("EditorialReview");
            AboutList.Items.Add("Help");
            AboutList.Items.Add("Images");
            AboutList.Items.Add("ItemAttributes");
            AboutList.Items.Add("ItemIds");
            AboutList.Items.Add("Large");
            AboutList.Items.Add("ListFull");
            AboutList.Items.Add("ListInfo");
            AboutList.Items.Add("ListItems");
            AboutList.Items.Add("ListMinimum");
            AboutList.Items.Add("ListmaniaLists");
            AboutList.Items.Add("Medium");
            AboutList.Items.Add("OfferFull");
            AboutList.Items.Add("OfferSummary");
            AboutList.Items.Add("Offers");
            AboutList.Items.Add("Request");
            AboutList.Items.Add("Reviews");
            AboutList.Items.Add("Salesrank");
            AboutList.Items.Add("Seller");
            AboutList.Items.Add("SellerListing");
            AboutList.Items.Add("Similarities");
            AboutList.Items.Add("Small");
            AboutList.Items.Add("Tracks");
            AboutList.Items.Add("TransactionDetails");
            AboutList.Items.Add("VariationMinimum");
            AboutList.Items.Add("VariationSummary");
            AboutList.Items.Add("Variations");
        }
    }
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Helpのサンプル</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="HelpTypeList" runat="server"
         OnSelectedIndexChanged="HelpTypeList_SelectedIndexChanged"
          AutoPostBack="True">
            <asp:ListItem>Operation</asp:ListItem>
            <asp:ListItem>ResponseGroup</asp:ListItem>
        </asp:DropDownList>
        <asp:DropDownList ID="AboutList" runat="server">
        </asp:DropDownList>
        <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>

ページ情報
[ トップ ]   [ 編集 | 凍結 | 差分 | バックアップ | 添付 | 複製 | 名前変更 | リロード ]   [ 新規 | 子ページ作成 | 一覧 | 単語検索 | 最終更新 | ヘルプ ]