*ListLookupのサンプルコード(C#) [#wd44a947] ここで紹介しているコードは[[こちらのプロキシクラス>../../../ProxyClass]]を使用しています。 リストIDからそのウィッシュリストを表示するサンプルです。TextBoxにリストのIDを入力します。 #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) { ListLookupRequest req = new ListLookupRequest(); //ウィッシュリストを指定 req.ListType = ListLookupRequestListType.WishList; req.ListTypeSpecified = true; //リストIDを指定 req.ListId = TextBox1.Text; req.ResponseGroup = new string[] { "ListInfo", "ListItems" }; ListLookup list = new ListLookup(); //あなたのAccess Key ID list.AWSAccessKeyId = "(あなたのAccessKeyID)"; //あなたのAssociate ID list.AssociateTag = "dobonnet-22"; list.Request = new ListLookupRequest[] { req }; AWSECommerceService aws = new AWSECommerceService(); ListLookupResponse res; try { //ListLookupオペレーションを実行し、結果を取得 res = aws.ListLookup(list); } catch (Exception ex) { Label1.Text = "エラー:" + Server.HtmlEncode(ex.Message); return; } if (res == null || res.Lists == null) { Label1.Text = "結果を取得できませんでした。"; return; } if (res.Lists[0].Request.Errors != null) { Label1.Text = "エラー:" + res.Lists[0].Request.Errors[0].Message; return; } if (res.Lists[0].List == null) { Label1.Text = "該当するリストが見つかりませんでした。"; return; } //結果を表示する Label1.Text = ""; Label1.Text += "<ul>\n"; foreach (List l in res.Lists[0].List) { Label1.Text += "<li><a href=\"" + l.ListURL + "\">" + l.ListName + "</a><br />\n"; Label1.Text += "商品の数 : " + l.TotalItems + "<br />\n"; //リスト内のアイテムを表示する if (l.ListItem != null) { Label1.Text += "<ul>\n"; foreach (Amazon.jp.v20060913.ListItem i in l.ListItem) { Label1.Text += "<li><b>" + i.Item.ItemAttributes.Title + "</b>\n"; Label1.Text += "<br />ASIN : " + i.Item.ASIN; Label1.Text += "<br />List Item ID : " + i.ListItemId; } Label1.Text += "<ul>\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> <asp:Button ID="Button1" runat="server" Text="検索" OnClick="Button1_Click" /><br /> </div> </form> <br /> <asp:Label ID="Label1" runat="server" EnableViewState="False"> </asp:Label> </body> </html> }} //これより下は編集しないでください #pageinfo(,2006-10-20 (金) 00:47:31,DOBON!,2006-10-20 (金) 02:14:29,DOBON!) #pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2006-10-20 (金) 00:47:31,DOBON!,2006-10-20 (金) 02:14:29,DOBON!) |