Skip to content

Instantly share code, notes, and snippets.

@kawahara
Created July 12, 2014 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kawahara/43d0d2d43ed5ff97275b to your computer and use it in GitHub Desktop.
Save kawahara/43d0d2d43ed5ff97275b to your computer and use it in GitHub Desktop.
Affiliate
<!DOCTYPE html>
<!--
Copyright (c) 2014 Rakuten, Inc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html>
<head>
<title>Sample</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
<style>
body {
padding-top: 20px;
padding-bottom: 30px;
}
</style>
</head>
<body role="document">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">私のサンプルページ</a>
</div>
<div class="navbar-collapse collapse">
<p class="navbar-text navbar-right">
</p>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="jumbotron">
<h1>私のホームページです</h1>
<p>これは、私がアフィリエイトやら楽天ウェブサービスやらを実験するすごいサイトです。どうだすごいだろ。</p>
</div>
<div class="container">
<div class="row">
<div class="col-md-6">
<h1>商品リンク</h1>
</div>
<div class="col-md-6">
<h1>モーションウィジェット</h1>
</div>
</div>
<div>
<h1>API</h1>
<div id="result">
</div>
<!-- Template -->
<script id="tmplResult" type="text/x-jquery-tmpl">
<div class="row">
{{each result.Items}}
{{if $index != 0 && $index % 4 == 0 }}
</div>
<div class="row">
{{/if}}
<div class="col-md-3">
{{if imageFlag}}
<a href="${affiliateUrl}" target="_blank">
<img src="${mediumImageUrls[0]}" />
</a>
{{/if}}
<p>
<a href="${affiliateUrl}" target="_blank">${itemName}</a>
</p>
</div>
{{/each}}
</div>
</script>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script>
// API Call
$.ajax({
url: "https://app.rakuten.co.jp/services/api/IchibaItem/Search/20140222?format=json&formatVersion=2&minPrice=5000&hits=8&keyword=%E3%81%86%E3%81%A9%E3%82%93&sort=-affiliateRate&affiliateId=0dd78f8a.26c4c8c0.0dd78f8b.0ee811d2&applicationId=902d5c47048ba262bd4e471475ea8c8a",
dataType: 'jsonp',
success: function(data) {
$("#tmplResult").tmpl({
result: data
}).appendTo("#result");
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment