*SellerLookupのサンプルコード(VB.NET) [#e10f70d3] ここで紹介しているコードは[[こちらのプロキシクラス>../../../ProxyClass]]を使用しています。 ここで紹介しているコードは[[こちらのC#のコード>../../CS/SellerLookup]]をVB.NETに変換したものです。 Amazon.co.jpの出品者へのカスタマーからの評価やフィードバックを表示するサンプルです。TextBoxに出品者のIDを入力します。 #code(vbnet){{ <%@ Page Language="VB" %> <%@ 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 Sub Button1_Click(ByVal sender As Object, _ ByVal e As EventArgs) Dim req As New SellerLookupRequest() '出品者のIDを指定 req.SellerId = New String() {TextBox1.Text} Dim sl As New SellerLookup() 'あなたのAccess Key ID sl.AWSAccessKeyId = "(あなたのAccessKeyID)" 'あなたのAssociate ID sl.AssociateTag = "dobonnet-22" sl.Request = New SellerLookupRequest() {req} Dim aws As New AWSECommerceService() Dim res As SellerLookupResponse Try 'SellerLookupオペレーションを実行し、結果を取得 res = aws.SellerLookup(sl) Catch ex As Exception Label1.Text = "エラー:" + Server.HtmlEncode(ex.Message) Return End Try If res Is Nothing OrElse res.Sellers Is Nothing Then Label1.Text = "結果を取得できませんでした。" Return End If If Not (res.Sellers(0).Request.Errors Is Nothing) Then Label1.Text = "エラー:" + _ res.Sellers(0).Request.Errors(0).Message Return End If If res.Sellers(0).Seller Is Nothing Then Label1.Text = "該当するSellerが見つかりませんでした。" Return End If '結果を表示 Label1.Text = "" Label1.Text += "<ul>" + vbLf Dim s As Seller For Each s In res.Sellers(0).Seller Label1.Text += "<li><b><a href=""" + _ s.GlancePage + """>" + s.Nickname + "</a></b>" + vbLf If s.AverageFeedbackRatingSpecified Then Label1.Text += "<br />過去1年間の評価 : " + _ s.AverageFeedbackRating.ToString() End If Label1.Text += "<br />Seller Id : " + s.SellerId Label1.Text += "<br />評価数:" + s.TotalFeedback Label1.Text += "<br />評価ページ数:" + _ s.TotalFeedbackPages '評価の表示 Label1.Text += "<br />最近の評価:" + _ s.TotalFeedbackPages If Not (s.SellerFeedback Is Nothing) Then Label1.Text += "<ul>" + vbLf Dim fb As SellerFeedbackFeedback For Each 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 Next fb Label1.Text += "</ul>" + vbLf End If '評価のサマリーの表示 Label1.Text += "<br />評価のサマリー:" + _ s.TotalFeedbackPages If Not (s.SellerFeedback Is Nothing) Then Label1.Text += "<ul>" + vbLf Dim fb As SellerFeedbackDateRange For Each fb In s.SellerFeedbackSummary Label1.Text += "<li>評価期間 : " + fb.Period Label1.Text += "<ul>" + vbLf Dim r As SellerFeedbackDateRangeSellerFeedbackRating For Each r In fb.SellerFeedbackRating Label1.Text += "<li>評価 : " + r.Type Label1.Text += "<br />評価数 : " + r.Count Label1.Text += "<br />割合 : " + _ r.Percentage + "%" Next r Label1.Text += "</ul>" + vbLf Next fb Label1.Text += "</ul>" + vbLf End If Next s Label1.Text += "</ul>" + vbLf End Sub </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" OnClick="Button1_Click" Text="送信" /><br /> </div> </form> <br /> <asp:Label ID="Label1" runat="server" EnableViewState="False"> </asp:Label> </body> </html> }} //これより下は編集しないでください #pageinfo(,2006-10-20 (金) 00:55:22,DOBON!,2006-10-20 (金) 02:20:04,DOBON!) |