DoboWiki
Top
> 自由区/Webサービス紹介/Amazon E-Commerce Service/Code/CS/SimilarityLookup をテンプレートにして作成
自由区/Webサービス紹介/Amazon E-Commerce Service/Code/CS/SimilarityLookup をテンプレートにして作成
開始行:
*SimilarityLookupのサンプルコード(C#) [#i60028fd]
ここで紹介しているコードは[[こちらのプロキシクラス>../../...
Amazon.co.jpで指定した商品に類似した商品のリストを表示す...
#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...
{
SimilarityLookupRequest req = new SimilarityLooku...
//類似した商品を調べたい商品のASINを指定
req.ItemId = new string[] { TextBox1.Text };
SimilarityLookup sl = new SimilarityLookup();
//あなたのAccess Key ID
sl.AWSAccessKeyId = "(あなたのAccessKeyID)";
//あなたのAssociate ID
sl.AssociateTag = "dobonnet-22";
sl.Request = new SimilarityLookupRequest[] { req };
AWSECommerceService aws = new AWSECommerceService...
SimilarityLookupResponse res;
try
{
//SimilarityLookupオペレーションを実行し、結...
res = aws.SimilarityLookup(sl);
}
catch (Exception ex)
{
Label1.Text = "エラー:" + Server.HtmlEncode(...
return;
}
if (res == null || res.Items == null)
{
Label1.Text = "結果を取得できませんでした。";
return;
}
if (res.Items[0].Request.Errors != null)
{
Label1.Text = "エラー:" +
res.Items[0].Request.Errors[0].Message;
return;
}
if (res.Items[0].Item == null)
{
Label1.Text = "該当する商品が見つかりませんで...
return;
}
//結果の表示
Label1.Text = "";
Label1.Text += "この商品を買った人はこんな商品も...
" :<br />";
Label1.Text += "<ul>\n";
foreach (Item i in res.Items[0].Item)
{
Label1.Text +=
"<li><b><a href=\"" + i.DetailPageURL + "...
i.ItemAttributes.Title + "</a></b><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">ASIN : </label>
<asp:TextBox ID="TextBox1" runat="server"></asp:T...
<asp:Button ID="Button1" runat="server" OnClick="...
Text="送信" /><br />
</div>
</form>
<br />
<asp:Label ID="Label1" runat="server" EnableViewState...
</asp:Label>
</body>
</html>
}}
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2006-1...
終了行:
*SimilarityLookupのサンプルコード(C#) [#i60028fd]
ここで紹介しているコードは[[こちらのプロキシクラス>../../...
Amazon.co.jpで指定した商品に類似した商品のリストを表示す...
#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...
{
SimilarityLookupRequest req = new SimilarityLooku...
//類似した商品を調べたい商品のASINを指定
req.ItemId = new string[] { TextBox1.Text };
SimilarityLookup sl = new SimilarityLookup();
//あなたのAccess Key ID
sl.AWSAccessKeyId = "(あなたのAccessKeyID)";
//あなたのAssociate ID
sl.AssociateTag = "dobonnet-22";
sl.Request = new SimilarityLookupRequest[] { req };
AWSECommerceService aws = new AWSECommerceService...
SimilarityLookupResponse res;
try
{
//SimilarityLookupオペレーションを実行し、結...
res = aws.SimilarityLookup(sl);
}
catch (Exception ex)
{
Label1.Text = "エラー:" + Server.HtmlEncode(...
return;
}
if (res == null || res.Items == null)
{
Label1.Text = "結果を取得できませんでした。";
return;
}
if (res.Items[0].Request.Errors != null)
{
Label1.Text = "エラー:" +
res.Items[0].Request.Errors[0].Message;
return;
}
if (res.Items[0].Item == null)
{
Label1.Text = "該当する商品が見つかりませんで...
return;
}
//結果の表示
Label1.Text = "";
Label1.Text += "この商品を買った人はこんな商品も...
" :<br />";
Label1.Text += "<ul>\n";
foreach (Item i in res.Items[0].Item)
{
Label1.Text +=
"<li><b><a href=\"" + i.DetailPageURL + "...
i.ItemAttributes.Title + "</a></b><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">ASIN : </label>
<asp:TextBox ID="TextBox1" runat="server"></asp:T...
<asp:Button ID="Button1" runat="server" OnClick="...
Text="送信" /><br />
</div>
</form>
<br />
<asp:Label ID="Label1" runat="server" EnableViewState...
</asp:Label>
</body>
</html>
}}
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2006-1...
ページ名:
▲
▼
[
トップ
] [
新規
|
子ページ作成
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]