DoboWiki
Top
> 自由区/Webサービス紹介/Amazon E-Commerce Service/Code/CS/ListSearch をテンプレートにして作成
自由区/Webサービス紹介/Amazon E-Commerce Service/Code/CS/ListSearch をテンプレートにして作成
開始行:
*ListSearchのサンプルコード(C#) [#na21ccfa]
ここで紹介しているコードは[[こちらのプロキシクラス>../../...
Amazon.co.jpのウィッシュリストを検索するサンプルです。Tex...
#code(csharp){{
<%@ Page Language="C#" %>
<%@ Import Namespace="Amazon.jp.v20060913" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs...
{
ListSearchRequest req = new ListSearchRequest();
//Amazon.co.jpではListTypeにはWishListしか指定で...
req.ListType = ListSearchRequestListType.WishList;
//リスト作成者の名前で検索する
req.Name = TextBox1.Text;
//ListIdを取得するため、ListMinimumを追加する
req.ResponseGroup = new string[]
{ "Request", "ListInfo", "ListMinimum" };
ListSearch list = new ListSearch();
//あなたのAccess Key ID
list.AWSAccessKeyId = "(あなたのAccessKeyID)";
//あなたのAssociate ID
list.AssociateTag = "dobonnet-22";
list.Request = new ListSearchRequest[] { req };
AWSECommerceService aws = new AWSECommerceService...
ListSearchResponse res;
try
{
//ListSearchオペレーションを実行し、結果を取得
res = aws.ListSearch(list);
}
catch (Exception ex)
{
Label1.Text = "エラー:" + Server.HtmlEncode(...
return;
}
if (res == null || res.Lists == null)
{
Label1.Text = "結果を取得できませんでした。";
return;
}
if (res.Lists[0].Request.Errors != null)
{
Label1.Text = "エラー:" + res.Lists[0].Reque...
return;
}
if (res.Lists[0].List == null)
{
Label1.Text = "該当するリストが見つかりません...
return;
}
//結果を表示する
Label1.Text = "";
Label1.Text += res.Lists[0].TotalResults +
"件見つかりました。<br />";
Label1.Text += "<ul>\n";
foreach (List l in res.Lists[0].List)
{
Label1.Text += "<li>" + "<a href=\"" + l.List...
l.ListName + " : " +
l.CustomerName + "</a><br />\n";
Label1.Text += "商品の数 : " + l.TotalItems +...
Label1.Text += "ListId : " + l.ListId + "<br ...
}
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">リスト作成者名 : </label>
<asp:TextBox ID="TextBox1" runat="server"></asp:T...
<asp:Button ID="Button1" runat="server" Text="検索"
OnClick="Button1_Click" /><br />
</div>
</form>
<br />
<asp:Label ID="Label1" runat="server" EnableViewState...
</asp:Label>
</body>
</html>
}}
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2006-1...
終了行:
*ListSearchのサンプルコード(C#) [#na21ccfa]
ここで紹介しているコードは[[こちらのプロキシクラス>../../...
Amazon.co.jpのウィッシュリストを検索するサンプルです。Tex...
#code(csharp){{
<%@ Page Language="C#" %>
<%@ Import Namespace="Amazon.jp.v20060913" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs...
{
ListSearchRequest req = new ListSearchRequest();
//Amazon.co.jpではListTypeにはWishListしか指定で...
req.ListType = ListSearchRequestListType.WishList;
//リスト作成者の名前で検索する
req.Name = TextBox1.Text;
//ListIdを取得するため、ListMinimumを追加する
req.ResponseGroup = new string[]
{ "Request", "ListInfo", "ListMinimum" };
ListSearch list = new ListSearch();
//あなたのAccess Key ID
list.AWSAccessKeyId = "(あなたのAccessKeyID)";
//あなたのAssociate ID
list.AssociateTag = "dobonnet-22";
list.Request = new ListSearchRequest[] { req };
AWSECommerceService aws = new AWSECommerceService...
ListSearchResponse res;
try
{
//ListSearchオペレーションを実行し、結果を取得
res = aws.ListSearch(list);
}
catch (Exception ex)
{
Label1.Text = "エラー:" + Server.HtmlEncode(...
return;
}
if (res == null || res.Lists == null)
{
Label1.Text = "結果を取得できませんでした。";
return;
}
if (res.Lists[0].Request.Errors != null)
{
Label1.Text = "エラー:" + res.Lists[0].Reque...
return;
}
if (res.Lists[0].List == null)
{
Label1.Text = "該当するリストが見つかりません...
return;
}
//結果を表示する
Label1.Text = "";
Label1.Text += res.Lists[0].TotalResults +
"件見つかりました。<br />";
Label1.Text += "<ul>\n";
foreach (List l in res.Lists[0].List)
{
Label1.Text += "<li>" + "<a href=\"" + l.List...
l.ListName + " : " +
l.CustomerName + "</a><br />\n";
Label1.Text += "商品の数 : " + l.TotalItems +...
Label1.Text += "ListId : " + l.ListId + "<br ...
}
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">リスト作成者名 : </label>
<asp:TextBox ID="TextBox1" runat="server"></asp:T...
<asp:Button ID="Button1" runat="server" Text="検索"
OnClick="Button1_Click" /><br />
</div>
</form>
<br />
<asp:Label ID="Label1" runat="server" EnableViewState...
</asp:Label>
</body>
</html>
}}
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2006-1...
ページ名:
▲
▼
[
トップ
] [
新規
|
子ページ作成
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]