もしもドロップシッピング用ブログパーツ

設定コードの生成

<使い方> 以下のファイルをコピーし、初期設定の部分を行なってください。
▼初期設定が必要な箇所

もしもショップIDshopId = ‘xxxxxx’;
もしもAPI認証コードmoshimoAuthCode = ‘xxxxxx’;
ヤフーデベロッパーIDyahooDeveloperId = ‘xxxxxx’;

▼ソースコード

<script type="text/javascript">
//<![CDATA[
/* 初期設定 */
//もしもショップID
shopId = 'xxxxxx';

//もしもAPI認証コード
moshimoAuthCode = 'xxxxxx';

//ヤフーデベロッパーID
yahooDeveloperId = 'xxxxxx';
/* ここまで */

IMAGE_BASE_URL = 'http://image.moshimo.com/item_image/';
ARTICLE_BASE_URL = 'http://www.moshimo.com/article/' + shopId + '/';

function adsMoshimo(param){
  param.blogUrl = location.href;
  param.shopId = shopId;
  param.moshimoAuthCode = moshimoAuthCode;
  param.yahooDeveloperId = yahooDeveloperId;
  param.sort_order = 'sales';
  param.list_per_page = '5';
  param.target_id = 'blogmatch';
  param.callback = 'adsAPI';

  var apireq = 'http://www.automaker-moshimo.com/api/blogmatch/moshimo.php?'+ objMquery(param);
  var script  = document.createElement( 'script' );
  script.type = 'text/javascript';
  script.charset = 'UTF-8';
  script.src  = apireq;
  document.body.appendChild( script );
}

// オブジェクトからクエリ文字列を生成する関数
function objMquery ( obj ) {
    var list = [];
    for( var key in obj ) {
        var k = encodeURIComponent(key);
        var v = encodeURIComponent(obj[key]);
        list[list.length] = k+'='+v;
    }
    var query = list.join( '&' );
    return query;
}

// コールバック関数
function adsAPI( data ) {
var moshimo_html = "";
for(var i=0; i<data.length; i++) {
var imagecode = data[i].IMAGECODE;
var articleid = data[i].ARTICLEID;
var name = data[i].NAME;
var shopprice = data[i].SHOPPRICE;

moshimo_html += '<p><img src=\"' + IMAGE_BASE_URL + imagecode + '/1/m.jpg\"><br />';
moshimo_html += '<a href=\"' + ARTICLE_BASE_URL + articleid + '/\">' + name + '</a><br />';
moshimo_html += '<span class=\"red\">' + shopprice + '円</span><br />';
}

document.getElementById('ads_moshimo').innerHTML = moshimo_html;
}

if (window.addEventListener) {
    window.addEventListener('load', adsMoshimo, false);
} else if (window.attachEvent) {
    window.attachEvent('onload', adsMoshimo);
} else {
    var old = window.onload;
    window.onload = (typeof old != 'function') ?
        adsMoshimo: function(e) { old(e); return adsMoshimo(e);};
}
//]]>
</script>
<style type="text/css">
div#ads_moshimo img {
	border: none;
}
div#ads_moshimo {
	font-size: 10px;
	width: 140px;
	text-align: center;
	border: 1px solid #999;
	padding: 5px;
	margin-bottom: 5px;
}
.red {
	color: #FF0000;
}
div#credit {
	width: 140px;
	text-align: center;
	font-size: 10px;
}
</style>
<div id="ads_moshimo">処理中...</div>
<!-- Moshimo API Web Services Attribution Snippet -->
<div id="credit">
<a href="http://www.moshimo.com/" target="_blank"><img src="http://www.moshimo.com/images/shop/service/api/banner-88-31.gif" width="88" height="31" alt="Moshimo API - 副業ならもしもドロップシッピング" style="border:0;"></a><br />
<a href="http://www.automaker-moshimo.com/">powered by amm</a></div>
RSS FEED