";
}
// 検索結果描画(全API共通)
function vcpage_func( $atts, $content = null ) {
// バリュコマなら
if ($_GET["pagetype"]=="vc") {
$vctoken= get_option('vc_search_token');
if ($vctoken=="") {$vctoken=VCTOKEN;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
$vc_yahoo_appid= get_option('vc_yahoo_appid');
if ($vc_yahoo_appid=="") {$vc_yahoo_appid=VC_YAHOO_APPID;}
$arr_sorts = array(
"0" => "スコア順",
"1" => "価格の高い順",
"2" => "価格の安い順" ,
"3" => "今日の売れ筋順",
"4" => "週間の売れ筋順" ,
"5" => "月間の売れ筋順"
);
$arr_categories = array(
"computers" => "コンピュータ",
"electronics" => "家電、AV機器",
"music" => "音楽、CD",
"books" => "本、コミック",
"dvd" => "DVD",
"fooddrink" => "フード、ドリンク",
"fashion" => "ファッション、アクセサリー",
"beautys" => "美容、健康",
"toysgameshobbies" => "おもちゃ、ホビー",
"recreationoutdoor" => "レジャー、アウトドア",
"homeinterior" => "生活、インテリア",
"babymaternity" => "ベビー、キッズ、マタニティ",
"officesupplies" => "ビジネス、ステーショナリー"
);
// フォームからGETで送られて受け取った値を変数へ格納
$v_category =$_GET["category"];
$v_keyword =$_GET["keyword"];
$v_page =$_GET["page"];
$v_sort_by =$_GET["sort_by"];
$v_sort_order =$_GET["sort_order"];
$v_sort_type =$_GET["sort_type"];
$v_sort_rank=$_GET["rank"];
$v_jancode=$_GET["jancode"];// JANコードはAPIで対応したら使う
$keyword = $v_keyword; //表示用
$v_keyword = urlencode(str_replace(" ", "+", trim($v_keyword))); //検索する場合は、トリムをかけて空白は「+」で繋ぐ(AND検索)
// デフォルト値の設定
if(!isset($v_page)) $v_page = "";
if(!isset($v_sort_by)) $v_sort_by = "";
if(!isset($v_sort_order)) $v_sort_order = "";
if(!isset($v_sort_type)) $v_sort_type = 0;
if(!isset($v_page) || $v_page == "") $v_page = 1;
if(!isset($v_sort_rank)) $v_sort_rank = "";
if(!isset($v_jancode)) $v_jancode = "";
// 並べ順の選択肢からパラメータを設定
switch ($v_sort_type) {
case 0:
$v_sort_by = "score";
$v_sort_order = "asc";
break;
case 1: //価格安い順
$v_sort_by = "price";
$v_sort_order = "desc";
break;
case 2: //価格高い順
$v_sort_by = "price";
$v_sort_order = "asc";
break;
case 3: //今日の売れ筋順
$v_sort_rank = "dayly";
break;
case 4: //週間の売れ筋順
$v_sort_rank = "weekly";
break;
case 5: //月間の売れ筋順
$v_sort_rank = "monthly";
break;
default:
break;
}
// バリューコマースリクエストURL組み立て
$vcurl = "http://webservice.valuecommerce.ne.jp/productdb/search?token=$vctoken&keyword=$v_keyword&category=$v_category&sort_by=$v_sort_by&sort_order=$v_sort_order&page=$v_page&results_per_page=10&rank=$v_sort_rank";
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=vc&keyword=$v_keyword&category=$v_category&sort_by=$v_sort_by&sort_order=$v_sort_order&sort_type=$v_sort_type&rank=$v_sort_rank";
// バリュコマsimpleXMLデータ取り出し配列変数に代入
$vcBuff = file_get_contents($vcurl);
$vcBuff = str_replace('vc:', 'vc', $vcBuff);
$vcBuff = str_replace('&', '&', $vcBuff);
$xml = simplexml_load_string ($vcBuff);
$resultcount = h($xml->channel->vcresultcount);
$totalpage = h($xml->channel->vcpagecount);
if ($resultcount != 0) {//検索件数が0件でない場合,変数$hitsに検索結果を格納します。
$hits = $xml->channel->item;
foreach ($hits as $hit) {
$itemname[] = h($hit->title);
$aflinkurl[] = str_replace('&', '&' ,h($hit->link));
// 画像URL取り出し
$img = array();
foreach($hit->vcimage as $vcimg) {
$img[]=$vcimg["url"];
}
if (strlen($img[1])) {
$imgurl[] = h($img[1]);
} else {
if (strlen($img[2])) {
$imgurl[] = h($img[2]);
} else {
$imgurl[] = WP_PLUGIN_URL."/vc_search/c_img/noimage.gif";
}
}
$price[] = h($hit->vcprice);
$description[] = h($hit->description);
$shopname[] = h($hit->vcmerchantName) . h($hit->vcsubStoreName);
$vcpvimg[] = $hit->vcpvImg;
$guid[] = h($hit->guid);
$jancode[] = h($hit->vcjanCode);
$souryou[]="";
$reviewnum[]="";
$reviewavr[]="";
$reviewurl[]="";
$faviconurl[]="";
}
}
// YAHOO!関連検索
$ysmhits = kanren($v_keyword);
// バリュコマならend
} else if ($_GET["pagetype"]=="yshopping") {
//ヤフーショッピングなら
$ysh_sid= get_option('ysh_sid');
if ($ysh_sid=="") {$ysh_sid=YSH_SID;}
$ysh_pid= get_option('ysh_pid');
if ($ysh_pid=="") {$ysh_pid=YSH_PID;}
$vc_yahoo_appid= get_option('vc_yahoo_appid');
if ($vc_yahoo_appid=="") {$vc_yahoo_appid=VC_YAHOO_APPID;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
$v_category =$_GET["category"];
$v_keyword =$_GET["keyword"];
$v_page =$_GET["page"];
$v_sort_by =$_GET["sort_by"];
$v_sort_order =$_GET["sort_order"];
$v_sort_type =$_GET["sort_type"];
$v_sort_rank=$_GET["rank"];
$v_jancode=$_GET["jancode"];
$keyword = $v_keyword; //表示用
$v_keyword = urlencode(trim($v_keyword));
// デフォルト値の設定
if(!isset($v_page)) $v_page = "";
if(!isset($v_sort_by)) $v_sort_by = "";
if(!isset($v_sort_order)) $v_sort_order = "";
if(!isset($v_sort_type)) $v_sort_type = 0;
if(!isset($v_page) || $v_page == "") $v_page = 1;
if(!isset($v_sort_rank)) $v_sort_rank = "";
if(!isset($v_jancode)) $v_jancode = "";
// 並べ順の選択肢からパラメータを設定
switch ($v_sort_type) {
case 0://商品価格安い順
$v_sort_order = "%2Bprice";
break;
case 1: //商品価格高い順
$v_sort_order = "-price";
break;
case 2: //おすすめ順
$v_sort_order = "-score";
break;
case 3: //売れ筋順
$v_sort_order = "-score";
break;
case 4: //アフィリエイト料率が高い順
$v_sort_order = "-affiliate";
break;
case 5: //レビュー件数が多い順
$v_sort_order = "-review_count";
break;
default:
break;
}
$offset = ($v_page*10)-9;
$ywsurl = "http://shopping.yahooapis.jp/ShoppingWebService/V1/itemSearch?appid=$vc_yahoo_appid&query=$v_keyword&hits=10&availability=1&affiliate_from=2.0&offset=$offset&sort=$v_sort_order";
$ywsurl = $ywsurl . "&affiliate_type=vc&affiliate_id=http%3A%2F%2Fck.jp.ap.valuecommerce.com%2Fservlet%2Freferral%3Fsid%3D" . $ysh_sid . "%26pid%3D" . $ysh_pid. "%26vc_url%3D";
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=yshopping&keyword=$v_keyword";
$vcBuff = file_get_contents($ywsurl );
$xml = simplexml_load_string ($vcBuff);
$resultcount = h($xml["totalResultsAvailable"]);
$totalpage = h($xml["totalResultsAvailable"] / 10);
if ($xml["totalResultsReturned"] != 0) {
$hits = $xml->Result->Hit;
foreach ($hits as $hit) {
$itemname[] = h($hit->Name);
$aflinkurl[] = h($hit->Url);
if ($hit->Store->Id == "engei" or $hit->Store->Id == "dinos" or $hit->Store->Id == "fobcoop" or $hit->Store->Id == "ottojapan") {
$imgurl[] = "c_img/linksakidegazo.gif";
} else {
$imgurl[] = h($hit->Image->Medium);
}
$price[] = h($hit->Price);
$description[] = h($hit->Description);
$shopname[] = h($hit->Store->Name);
$vcpvimg[]="";
$guid[]="";
$souryou[] = h($hit->Shipping->Name);
$reviewnum[] = h($hit->Review->Count);
$reviewavr[] = h($hit->Review->Rate);
$reviewurl[] = h($hit->Review->Url);
$faviconurl[] = "http://shopping.yahoo.co.jp/";
}
}
// YAHOO!関連検索
$ysmhits = kanren($v_keyword);
// ヤフーショッピングならend
} else if ($_GET["pagetype"]=="yauction") {
//ヤフーオークションなら
$yauc_sid= get_option('yauc_sid');
if ($yauc_sid=="") {$yauc_sid=YAUC_SID;}
$yauc_pid= get_option('yauc_pid');
if ($yauc_pid=="") {$yauc_pid=YAUC_PID;}
$vc_yahoo_appid= get_option('vc_yahoo_appid');
if ($vc_yahoo_appid=="") {$vc_yahoo_appid=VC_YAHOO_APPID;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
$v_category =$_GET["category"];
$v_keyword =$_GET["keyword"];
$v_page =$_GET["page"];
$v_sort_by =$_GET["sort_by"];
$v_sort_order =$_GET["sort_order"];
$v_sort_type =$_GET["sort_type"];
$v_sort_rank=$_GET["rank"];
$v_jancode=$_GET["jancode"];
$keyword = $v_keyword; //表示用
$v_keyword = urlencode(trim($v_keyword));
// デフォルト値の設定
if(!isset($v_page)) $v_page = "";
if(!isset($v_sort_by)) $v_sort_by = "";
if(!isset($v_sort_order)) $v_sort_order = "";
if(!isset($v_sort_type)) $v_sort_type = 0;
if(!isset($v_page) || $v_page == "") $v_page = 1;
if(!isset($v_sort_rank)) $v_sort_rank = "";
if(!isset($v_jancode)) $v_jancode = "";
switch ($v_sort_type) {
case 0://終了間際順
$v_sort_by = "end";
$v_sort_order = "a";//昇順
break;
case 1: //入札数が多い順
$v_sort_by = "bids";
$v_sort_order = "d";
break;
case 2: //現在価格安い順
$v_sort_by = "cbids";
$v_sort_order = "a";
break;
case 3: //現在価格高い順
$v_sort_by = "cbids";
$v_sort_order = "d";
break;
case 4: //即決価格安い順
$v_sort_by = "bidorbuy";
$v_sort_order = "a";
break;
default:
break;
}
$offset = ($v_page*10)-9;
$yacurl = "http://auctions.yahooapis.jp/AuctionWebService/V2/search?appid=$vc_yahoo_appid&query=$v_keyword&page=$v_page&sort=$v_sort_by&order=$v_sort_order";
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=yauction&keyword=$v_keyword";
$vcBuff = file_get_contents($yacurl);
$xml = simplexml_load_string ($vcBuff);
$resultcount = h($xml["totalResultsAvailable"] );
$totalpage = h($xml["totalResultsAvailable"] /50);
if ($xml["totalResultsReturned"] != 0) {//検索件数が0件でない場合,変数$hitsに検索結果を格納します。
$hits = $xml->Result->Item;
foreach ($hits as $hit) {
$itemname[] = h($hit->Title);
$aflinkurl[] = "http://ck.jp.ap.valuecommerce.com/servlet/referral?sid=$yauc_sid&pid=$yauc_pid&vc_url=" . urlencode(h($hit->AuctionItemUrl));
$img = array();
// 画像情報取り出し
if (strlen($hit->Image)) {
$imgurl[] = h($hit->Image);
} else {
$imgurl[] = "c_img/noimage.gif";
}
$pricebuff = h($hit->CurrentPrice);
$pricebuff = str_replace(' .00', '', $pricebuff);
$pricebuff = str_replace(',', '', $pricebuff);
$price[] = intval($pricebuff);
$description[] = "落札終了予定時間" . h($hit->EndTime);
$shopname[] = "Yahoo!オークション 出品者(ストア):" . h($hit->Seller->Id);
$vcpvimg[]="";
$guid[]="";
$jancode[]="";
$souryou[] = "";
$reviewnum[] = "";
$reviewavr[] = "";
$reviewurl[] = "";
$faviconurl[] = "http://auctions.yahoo.co.jp/jp/";
}
}
// YAHOO!関連検索
$ysmhits = kanren($v_keyword);
// ヤフーオークションならend
} else if ($_GET["pagetype"]=="amazon_vc") {
//Amazonなら
$amzacckey=get_option('amzacckey');
if ($amzacckey=="") {$amzacckey=AMZACCKEY;}
$amzseckey=get_option('amzseckey');
if ($amzseckey=="") {$amzseckey=AMZSECKEY;}
$amzassid=get_option('amzassid');
if ($amzassid=="") {$amzassid=AMZASSID;}
$vc_yahoo_appid= get_option('vc_yahoo_appid');
if ($vc_yahoo_appid=="") {$vc_yahoo_appid=VC_YAHOO_APPID;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
$v_category =$_GET["category"];
$v_keyword =$_GET["keyword"];
$v_page =$_GET["page"];
$v_sort_by =$_GET["sort_by"];
$v_sort_order =$_GET["sort_order"];
$v_sort_type =$_GET["sort_type"];
$v_sort_rank=$_GET["rank"];
$v_jancode=$_GET["jancode"];
$keyword = $v_keyword; //表示用
$v_keyword = urlencode(trim($v_keyword));
// デフォルト値の設定
if(!isset($v_page)) $v_page = "";
if(!isset($v_sort_by)) $v_sort_by = "";
if(!isset($v_sort_order)) $v_sort_order = "";
if(!isset($v_sort_type)) $v_sort_type = 0;
if(!isset($v_page) || $v_page == "") $v_page = 1;
if(!isset($v_sort_rank)) $v_sort_rank = "";
if(!isset($v_jancode)) $v_jancode = "";
// AmazonリクエストURL組み立て
$baseurl = 'http://ecs.amazonaws.jp/onca/xml';
$params = array();
$params['Service'] = 'AWSECommerceService';
$params['AWSAccessKeyId'] = $amzacckey;
$params['Version'] = '2009-03-31';
$params['Operation'] = 'ItemSearch';
$params['SearchIndex'] = 'Blended';
$params['Keywords'] = $v_keyword;
$params['AssociateTag'] = $amzassid;
$params['Condition'] = 'New';
$params['ContentType'] = 'text/xml';
$params['ResponseGroup'] = 'Medium,Reviews,OfferSummary';
$params['ItemPage'] = $v_page;
$params['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
// パラメータの順序を昇順に並び替えます
ksort($params);
$canonical_string = '';
foreach ($params as $k => $v) {
$canonical_string .= '&'.urlencode_rfc3986($k).'='.urlencode_rfc3986($v);
}
$canonical_string = substr($canonical_string, 1);
$parsed_url = parse_url($baseurl);
$string_to_sign = "GET\n{$parsed_url['host']}\n{$parsed_url['path']}\n{$canonical_string}";
$signature = base64_encode(hash_hmac('sha256', $string_to_sign, $amzseckey, true));
$awsurl = $baseurl.'?'.$canonical_string.'&Signature='.urlencode_rfc3986($signature);
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=amazon_vc&keyword=$v_keyword";
$vcBuff = file_get_contents($awsurl);
$xml = simplexml_load_string ($vcBuff);
$resultcount = h($xml->Items->TotalResults);
$totalpage = h($xml->Items->TotalPages);
if ($resultcount != 0) {//検索件数が0件でない場合,変数$hitsに検索結果を格納します。
$hits = $xml->Items->Item;
foreach ($hits as $hit) {
$itemname[] = h($hit->ItemAttributes->Title);
$aflinkurl[] = h($hit->DetailPageURL);
$imgurl[] = h($hit->MediumImage->URL);
$price[] = h($hit->OfferSummary->LowestNewPrice->Amount);
$description[] = h($hit->EditorialReviews->EditorialReview->Content);
$shopname[] = "Amazon.co.jp";
$vcpvimg[]="";
$guid[]="";
$jancode[]="";
$souryou[] = "";
$reviewnum[] = h($hit->CustomerReviews->TotalReviews);
$reviewavr[] = h($hit->CustomerReviews->AverageRating);
$reviewurl[] = "";
$faviconurl[] = "http://www.amazon.co.jp/";
}
}
// YAHOO!関連検索
$ysmhits = kanren($v_keyword);
// Amazonならend
} else if ($_GET["pagetype"]=="ls") {
//リンクシェアなら
$lstoken= get_option('ls_search_token');
if ($lstoken=="") {$lstoken=LSTOKEN;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
$ls_yahoo_appid= get_option('vc_yahoo_appid');
if ($vc_yahoo_appid=="") {$vc_yahoo_appid=VC_YAHOO_APPID;}
$arr_sorts = array(
"0" => "参考価格の安い順",
"1" => "参考価格の高い順"
);
// フォームからGETで送られて受け取った値を変数へ格納
$ls_category =$_GET["category"];
$ls_keyword =$_GET["keyword"];
$v_page =$_GET["page"];
$ls_sort_by =$_GET["sort_by"];
$ls_sort_order =$_GET["sort_order"];
$ls_sort_type =$_GET["sort_type"];
$ls_sort_rank=$_GET["rank"];
$ls_jancode=$_GET["jancode"];// JANコードはAPIで対応したら使う
$keyword = $ls_keyword; //表示用
$ls_keyword = urlencode('"'.trim($ls_keyword).'"'); //検索する場合は、トリムをかけて引用符で囲む
// デフォルト値の設定
if(!isset($v_page )) $v_page = "1";
if(!isset($ls_sort_by)) $ls_sort_by = "";
if(!isset($ls_sort_order)) $ls_sort_order = "";
if(!isset($ls_sort_type)) $ls_sort_type = 0;
if(!isset($v_page ) || $v_page == "") $v_page = 1;
if(!isset($ls_sort_rank)) $ls_sort_rank = "";
if(!isset($ls_jancode)) $ls_jancode = "";
// 並べ順の選択肢からパラメータを設定
switch ($ls_sort_type) {
case 0:
$ls_sort_order = "asc";
break;
case 1: //価格安い順
$ls_sort_order = "dsc";
break;
default:
break;
}
// リンクシェアリクエストURL組み立て
$lsurl = "http://feed.linksynergy.com/productsearch?token=$lstoken&keyword=$ls_keyword&max=10&pagenumber=$v_page&sort=retailprice&sorttype=$ls_sort_order";
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=ls&keyword=".urlencode($keyword)."&sort=retailprice&sorttype=$ls_sort_order";
// リンクシェアsimpleXML,データ取り出し配列変数に代入
$lsBuff = file_get_contents($lsurl);
$xml = simplexml_load_string ($lsBuff);
$resultcount = h($xml->TotalMatches);
$totalpage = h($xml->TotalPages);
if ($resultcount != 0) {//検索件数が0件でない場合,変数$hitsに検索結果を格納します。
$hits = $xml->item;
foreach ($hits as $hit) {
if (!is_numeric(mb_strpos($hit->merchantname,"携帯"))) {
$itemname[] = h($hit->productname);
$aflinkurl[] = $hit->linkurl;
if (strlen($hit->imageurl)) {
$imgurl[] = h($hit->imageurl);
} else {
$imgurl[] = "c_img/noimage.gif";
}
$price[] = h($hit->price);
$description[] = h($hit->description->long);
$shopname[] = h($hit->merchantname);
$vcpvimg[]="";
$guid[]="";
$jancode[]="";
$souryou[] = "";
$reviewnum[] = "";
$reviewavr[] = "";
$reviewurl[] = "";
$faviconurl[] = h($hit->imageurl);
}
} //foreach
} // if $resultcoundt
// YAHOO!関連検索
$ysmhits = kanren($ls_keyword);
//リンクシェアならend
} else if ($_GET["pagetype"]=="jalan") {
// じゃらんなら
$jalantoken= get_option('jalan_search_token');
if ($jalantoken=="") {$jalantoken=JALANTOKEN;}
$jalan_sid= get_option('jalan_sid');
if ($jalan_sid=="") {$jalan_sid=JALAN_SID;}
$jalan_pid= get_option('jalan_pid');
if ($jalan_pid=="") {$jalan_sid=JALAN_PID;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
// フォームからGETで送られて受け取った値を変数へ格納
$v_page =$_GET["page"];
$jalan_pref =$_GET["pref "];
$jalan_l_area =$_GET["l_area"];
$jalan_s_area =$_GET["s_area"];
// デフォルト値の設定
if(!isset($v_page)) $v_page = "1";
// じゃらんリクエストURL組み立て
$start = 10*($v_page-1)+1;
if ($start< 0) {$start=1;}
$jalanurl = "http://jws.jalan.net/APIAdvance/HotelSearch/V1/?key=$jalantoken&pref=$jalan_pref&l_area=$jalan_l_area&s_area=$jalan_s_area&count=10&start=$start";
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=jalan&pref=$jalan_pref&l_area=$jalan_l_area&s_area=$jalan_s_area";
//if (isset($jalan_pref)) {
$jalanBuff = @file_get_contents($jalanurl);
$xml = @simplexml_load_string ($jalanBuff);
$resultcount = h($xml->NumberOfResults);
$totalpage = h($xml->NumberOfResults) / 10;
$hits = $xml->Hotel;
if (!$resultcount==0) {
foreach ($hits as $hit) {
$itemname[] = h($hit->HotelName);
$aflinkurl[] = "http://ck.jp.ap.valuecommerce.com/servlet/referral?sid=$jalan_sid&pid=$jalan_pid&vc_url=".urlencode($hit->HotelDetailURL);
//$aflinkurl[] = h($hit->HotelDetailURL);
if (strlen($hit->PictureURL)) {
$imgurl[] = h($hit->PictureURL);
} else {
$imgurl[] = "c_img/noimage.gif";
}
$price[] = h($hit->price);
$description[] = h($hit->HotelCatchCopy).h($hit->HotelCaption);
$shopname[] = h($hit->HotelName);
$vcpvimg[]="";
$guid[]="";
$jancode[]="";
$souryou[] = "";
$reviewnum[] = "";
$reviewavr[] = "";
$reviewurl[] = "";
$faviconurl[] = h($hit->HotelDetailURL);
$vcpvimg[] = "";
} //foreach
} // if
// じゃらんend
} else if ($_GET["pagetype"]=="actr") {
// アクセストレードなら
$attoken= get_option('attoken');
if ($attoken=="") {$attoken=ATTOKEN;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
// フォームからGETで送られて受け取った値を変数へ格納
$v_category =$_GET["category"];
$v_keyword =$_GET["keyword"];
$v_page =$_GET["page"];
$v_sort_by =$_GET["sort_by"];
$v_sort_order =$_GET["sort_order"];
$v_sort_type =$_GET["sort_type"];
$v_sort_rank=$_GET["rank"];
$v_jancode=$_GET["jancode"];
$keyword = $v_keyword; //表示用
$v_keyword = urlencode(trim($v_keyword));
// デフォルト値の設定
if(!isset($v_page)) $v_page = "";
if(!isset($v_sort_by)) $v_sort_by = "";
if(!isset($v_sort_order)) $v_sort_order = "";
if(!isset($v_sort_type)) $v_sort_type = 0;
if(!isset($v_page) || $v_page == "") $v_page = 1;
if(!isset($v_sort_rank)) $v_sort_rank = "";
if(!isset($v_jancode)) $v_jancode = "";
switch ($v_sort_type) {
case 0://終了間際順
$v_sort_by = "end";
$v_sort_order = "a";//昇順
break;
case 1: //入札数が多い順
$v_sort_by = "bids";
$v_sort_order = "d";
break;
case 2: //現在価格安い順
$v_sort_by = "cbids";
$v_sort_order = "a";
break;
case 3: //現在価格高い順
$v_sort_by = "cbids";
$v_sort_order = "d";
break;
case 4: //即決価格安い順
$v_sort_by = "bidorbuy";
$v_sort_order = "a";
break;
default:
break;
}
// アクトレリクエストURL組み立て
$aturl = "http://xml.accesstrade.net/at/ws.html?ws_type=searchgoods&ws_ver=1&ws_id=$attoken&search=$v_keyword&row=10&sort1=3";
echo $aturl ;
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=actr&keyword=$v_keyword";
$actrBuff = file_get_contents($aturl) ;
$xml = simplexml_load_string($actrBuff);
$resultcount = h($xml->TotalCount);
$totalpage = h($xml->TotalPage);
$hits = $xml->Goods;
if (!$resultcount==0) {
foreach ($hits as $hit) {
$itemname[] = h($hit->GoodsName);
$aflinkurl[] = h($hit->LinkCode);
$img = array();
// 画像情報取り出し
if (strlen($hit->ImageUrl)) {
$imgurl[] = h($hit->ImageUrl);
} else {
$imgurl[] = "c_img/noimage.gif";
}
$price[] = h($hit->Price);
$description[] = h($hit->Explanation);
$shopname[] = h($hit->ShopName);
$souryou[] = "";
$reviewnum[] = "";
$reviewavr[] = "";
$reviewurl[] = "";
$faviconurl[] = h($hit->ImageUrl);
} //foreach
} // if
// YAHOO!関連検索
$ysmhits = kanren($v_keyword);
// アクセストレードならend
} else if ($_GET["pagetype"]=="rakuten") {
// 楽天市場なら
$rakutentoken= get_option('rakuten_search_token');
if ($rakutentoken=="") {$rakutentoken=RAKUTENTOKEN;}
$rakutenaffid= get_option('rakuten_affiliate_id');
if ($rakutenaffid=="") {$rakutenaffid=RAKUTENAFFID;}
$vcpagepage= get_option('vc_search_page');
if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;}
$vc_yahoo_appid= get_option('vc_yahoo_appid');
if ($vc_yahoo_appid=="") {$vc_yahoo_appid=VC_YAHOO_APPID;}
// フォームからGETで送られて受け取った値を変数へ格納
$rakuten_category =$_GET["category"];
$rakuten_keyword =$_GET["keyword"];
$v_page =$_GET["page"];
$rakuten_sort_by =$_GET["sort_by"];
$rakuten_sort_order =$_GET["sort_order"];
$rakuten_sort_type =$_GET["sort_type"];
$rakuten_sort_rank=$_GET["rank"];
$rakuten_jancode=$_GET["jancode"];
$keyword = urlencode($rakuten_keyword);
// デフォルト値の設定
if(!isset($v_page )) $v_page = "1";
if(!isset($rakuten_sort_by)) $rakuten_sort_by = "";
if(!isset($rakuten_sort_order)) $rakuten_sort_order = "";
if(!isset($rakuten_sort_type)) $rakuten_sort_type = 0;
if(!isset($v_page ) || $v_page == "") $v_page = 1;
if(!isset($rakuten_sort_rank)) $rakuten_sort_rank = "";
if(!isset($rakuten_jancode)) $rakuten_jancode = "";
$arr_sorts = array(
"0" => "楽天標準ソート順",
"3" => "レビュー件数順(昇順)",
"4" => "レビュー件数順(降順)" ,
"5" => "価格順(昇順)",
"6" => "価格順(降順)" ,
"7" => "商品更新日時順(昇順)",
"8" => "商品更新日時順(降順)"
);
$arr_categories = array(
"0"=>"すべての商品",
"101240"=>"CD・DVD・楽器",
"100804"=>"インテリア・寝具・収納",
"101164"=>"おもちゃ・ホビー・ゲーム",
"100533"=>"キッズ・ベビー・マタニティ",
"215783"=>"キッチン・日用品雑貨・文具",
"216129"=>"ジュエリー・腕時計",
"101070"=>"スポーツ・アウトドア",
"100938"=>"ダイエット・健康",
"100316"=>"水・ソフトドリンク",
"100026"=>"水・ソフトドリンク",
"100026"=>"パソコン・周辺機器",
"216131"=>"バッグ・小物・ブランド雑貨",
"100371"=>"レディースファッション・靴",
"100005"=>"花・ガーデン・DIY",
"101213"=>"ペット・ペットグッズ",
"211742"=>"家電・AV・カメラ",
"101114"=>"車・バイク",
"100227"=>"食品",
"100939"=>"美容・コスメ・香水",
"200162"=>"本・雑誌・コミック",
"101381"=>"旅行・出張・チケット",
"200163"=>"不動産・住まい",
"101438"=>"学び・サービス・保険",
"100000"=>"百貨店・総合通販・ギフト",
"402853"=>"デジタルコンテンツ",
"503190"=>"車用品・バイク用品",
"100433"=>"インナー・下着・ナイトウエア",
"510901"=>"日本酒・焼酎",
"510915"=>"ビール・洋酒",
"551167"=>"スイーツ",
"551169"=>"医薬品・コンタクト・介護",
"551177"=>"メンズファッション・靴",
);
// 並べ順の選択肢からパラメータを設定
switch ($rakuten_sort_type) {
case 0: //楽天標準ソート順
$rakuten_sort_order = "standard";
break;
case 1: //アフィリエイト料率順(昇順)
$rakuten_sort_order = "+affiliateRate";
break;
case 2: //アフィリエイト料率順(降順)
$rakuten_sort_order = "-affiliateRate";
break;
case 3: //レビュー件数順(昇順)
$rakuten_sort_order = "+reviewCount";
break;
case 4: //レビュー件数順(降順)
$rakuten_sort_order = "-reviewCount";
break;
case 5: //価格順(昇順)
$rakuten_sort_order = "+itemPrice";
break;
case 6: //価格順(降順)
$rakuten_sort_order = "-itemPrice";
break;
case 7: //商品更新日時順(昇順)
$rakuten_sort_order = "+updateTimestamp";
break;
case 8: //商品更新日時順(降順)
$rakuten_sort_order = "-updateTimestamp";
break;
default:
break;
}
if ((! function_exists('is_mobile') || ! is_mobile()) && (! function_exists('is_ktai') || ! is_ktai())) {
// PCであれば・・・
$rwsurl = "http://api.rakuten.co.jp/rws/1.13/rest?developerId=$rakutentoken&affiliateId=$rakutenaffid&operation=ItemSearch&version=2009-02-03&keyword=$keyword&hits=10&availability=1&page=$v_page&genreId=$rakuten_category&sort=".urlencode($rakuten_sort_order);
} else {
$rwsurl = "http://api.rakuten.co.jp/rws/1.13/rest?developerId=$rakutentoken&affiliateId=$rakutenaffid&operation=ItemSearch&version=2009-02-03&keyword=$keyword&hits=10&availability=1&page=$v_page&genreId=$rakuten_category&carrier=1&sort=".urlencode($rakuten_sort_order);
}
// 改ページ用パラメータ
$params = $vcpagepage . "pagetype=rakuten&keyword=$keyword&category=".$rakuten_category."&sort=".urlencode($rakuten_sort_order);
$rwsBuff = file_get_contents($rwsurl );
$rwsBuff = str_replace('header:Header', 'headerHeader', $rwsBuff);
$rwsBuff = str_replace('itemSearch:ItemSearch', 'itemSearchItemSearch', $rwsBuff);
$xml = simplexml_load_string ($rwsBuff);
$hits = $xml->Body->itemSearchItemSearch->Items->Item;
$resultcount = h($xml->Body->itemSearchItemSearch->count);
$totalpage = h($xml->Body->itemSearchItemSearch->pageCount);
if (!$resultcount==0) {
foreach ($hits as $hit) {
$itemname[] = h($hit->itemName);
$aflinkurl[] = h($hit->affiliateUrl);
if (strlen($hit->mediumImageUrl)) {
$imgurl[] = h($hit->mediumImageUrl);
} else {
$imgurl[] = "c_img/noimage.gif";
}
$price[] = h($hit->itemPrice);
$description[] = h($hit->itemCaption);
$shopname[] = h($hit->shopName);
$vcpvimg[] = "";
$guid[]="";
$jancode[]="";
//送料フラグ postageFlag 0:送料込
//1:送料別
if ($hit->postageFlag == 0) {
$souryou[] = "送料無料";
} else {
$souryou[] = "送料別";
}
$reviewnum[] = h($hit->reviewCount);
$reviewavr[] = h($hit->reviewAverage);
$reviewurl[] = "";
$faviconurl[] = "http://www.rakuten.co.jp";
}
}
}
// YAHOO!関連検索
$ysmhits = kanren($rakuten_keyword);
// php end
?>
検索した結果、見つかりませんでした。今YAHOO!SHOPPINGで人気の急上昇キーワードで検索してみませんか?
急上昇キーワード: Query); ?>
null, 'jancode' => null, 'category' => null, 'sort_type' => null, ), $atts)); if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=vc&keyword='.$keyword; } else if (isset($jancode)) { // JANコード指定の場合※現時点ではAPIで対応していないので機能しない $linkurl = $vcpagepage.'jancode='.$jancode; } else { // それ以外の[vc]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=vc&keyword='.$keyword; } $v_keyword = urlencode(str_replace(" ", "+", trim($v_keyword))); //検索する場合は、トリムをかけて空白は「+」で繋ぐ(AND検索) // 並べ順の選択肢からパラメータを設定 switch ($v_sort_type) { case 0: $v_sort_by = "score"; $v_sort_order = "asc"; break; case 1: //価格安い順 $v_sort_by = "price"; $v_sort_order = "desc"; break; case 2: //価格高い順 $v_sort_by = "price"; $v_sort_order = "asc"; break; case 3: //今日の売れ筋順 $v_sort_rank = "dayly"; break; case 4: //週間の売れ筋順 $v_sort_rank = "weekly"; break; case 5: //月間の売れ筋順 $v_sort_rank = "monthly"; break; default: break; } // バリューコマースリクエストURL組み立て $vcurl = "http://webservice.valuecommerce.ne.jp/productdb/search?token=$vctoken&keyword=$v_keyword&category=$v_category&sort_by=$v_sort_by&sort_order=$v_sort_order&results_per_page=1&rank=$v_sort_rank"; // バリュコマsimpleXMLデータ取り出し配列変数に代入 $vcBuff = file_get_contents($vcurl); $vcBuff = str_replace('vc:', 'vc', $vcBuff); $vcBuff = str_replace('&', '&', $vcBuff); $xml = simplexml_load_string ($vcBuff); $hits = $xml->channel->item; foreach ($hits as $hit) { $itemname[] = h($hit->title); $aflinkurl[] = str_replace('&', '&' ,h($hit->link)); // 画像URL取り出し $img = array(); foreach($hit->vcimage as $vcimg) { $img[]=$vcimg["url"]; } if (strlen($img[1])) { $imgurl[] = h($img[1]); } else { if (strlen($img[2])) { $imgurl[] = h($img[2]); } else { $imgurl[] = WP_PLUGIN_URL."/vc_search/c_img/noimage.gif"; } } $price[] = h($hit->vcprice); $description[] = h($hit->description); $shopname[] = h($hit->vcmerchantName) . h($hit->vcsubStoreName); $vcpvimg[] = $hit->vcpvImg; $guid[] = h($hit->guid); $jancode[] = h($hit->vcjanCode); } $resultcount = h($xml->channel->vcresultcount); // 商品表示部分 // php end ?> $value) { $ret =""; $ret =DrawPageItem($itemname[$key],$imgurl[$key],$aflinkurl[$key],$price[$key],$jancode[$key],$description[$key],$vcpvimg[$key],$guid[$key],$shopname[$key],$faviconurl[$key]); $ret =$ret .''; } //foreach } else { $ret =''; } ?> null, 'jancode' => null, 'category' => null, 'sort_type' => null, ), $atts)); if (isset($keyword)) { // 自由テキストリンクの場合 $linkurl = $vcpagepage.'pagetype=vc&keyword='.$keyword; } else if (isset($jancode)) { // JANコード指定の場合※現時点ではAPIで対応していないので機能しない $linkurl = $vcpagepage.'jancode='.$jancode; } else { // それ以外の[lsitem]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= $content; $linkurl = $vcpagepage.'pagetype=vc&keyword='.$keyword; } $ls_keyword = urlencode('"'.trim($keyword).'"'); //検索する場合は、トリムをかける // デフォルト値の設定 if(!isset($ls_page)) $ls_page = "1"; if(!isset($ls_sort_by)) $ls_sort_by = ""; if(!isset($ls_sort_order)) $ls_sort_order = ""; if(!isset($ls_sort_type)) $ls_sort_type = 0; if(!isset($ls_page) || $ls_page == "") $ls_page = 1; if(!isset($ls_sort_rank)) $ls_sort_rank = ""; if(!isset($ls_jancode)) $ls_jancode = ""; // 並べ順の選択肢からパラメータを設定 switch ($ls_sort_type) { case 0: $ls_sort_order = "asc"; break; case 1: //価格安い順 $ls_sort_order = "dsc"; break; default: break; } // リンクシェアリクエストURL組み立て $lsurl = "http://feed.linksynergy.com/productsearch?token=$lstoken&keyword=$ls_keyword&max=1&pagenumber=$ls_page&sort=retailprice&sorttype=$ls_sort_order"; // リンクシェアsimpleXML,データ取り出し配列変数に代入 $lsBuff = file_get_contents($lsurl); $xml = simplexml_load_string ($lsBuff); $hits = $xml->item; foreach ($hits as $hit) { if (!is_numeric(mb_strpos($hit->merchantname,"携帯"))) { $itemname[] = h($hit->productname); $aflinkurl[] = h($hit->$linkurl); if (strlen($hit->imageurl)) { $imgurl[] = h($hit->imageurl); } else { $imgurl[] = "c_img/noimage.gif"; } $price[] = h($hit->price); $description[] = h($hit->description->long); $shopname[] = h($hit->merchantname); $vcpvimg[]=""; $guid[]=""; $jancode[]=""; $souryou[] = ""; $reviewnum[] = ""; $reviewavr[] = ""; $reviewurl[] = ""; $faviconurl[] = h($hit->imageurl); } } //foreach $resultcount = h($xml->TotalMatches); $totalpage = h($xml->TotalPages); // 商品表示部分 // php end ?> $value) { $ret =""; $ret =DrawPageItem($itemname[$key],$imgurl[$key],$aflinkurl[$key],$price[$key],$jancode[$key],$description[$key],$vcpvimg[$key],$guid[$key],$shopname[$key],$faviconurl[$key]); $ret =$ret .''; } //foreach } else { $ret ='
'; } ?> null, 'jancode' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=vc&keyword='.$keyword; } else if (isset($jancode)) { // JANコード指定の場合※現時点ではAPIで対応していないので機能しない $linkurl = $vcpagepage.'jancode='.$jancode; } else { // それ以外の[vc]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=vc&keyword='.$keyword; } // カテゴリー指定 if (isset($category)) { $linkurl = $linkurl."&category=". $category; } // ソート指定 if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(リンクシェア) function ls_func( $atts, $content = null ) { // [ls]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'jancode' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=ls&keyword='.$keyword; } else if (isset($jancode)) { // JANコード指定の場合※現時点ではAPIで対応しているか調べるのは後まわし $linkurl = $vcpagepage.'jancode='.$jancode; } else { // それ以外の[ls]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=ls&keyword='.$keyword; } // カテゴリー指定 if (isset($category)) { $linkurl = $linkurl."&category=". $category; } // ソート指定 if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(じゃらん) function jalan_func( $atts, $content = null ) { // [jalan]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=jalan&keyword='.$keyword; } else { // それ以外の[jalan]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=jalan&keyword='.$keyword; } // ソート指定(未実装) if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(楽天市場) function rakuten_func( $atts, $content = null ) { // [rakuten]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=rakuten&keyword='.$keyword; } else { // それ以外の[rakuten]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=rakuten&keyword='.$keyword; } // カテゴリー指定 if (isset($category)) { $linkurl = $linkurl."&category=". $category; } // ソート指定 if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(ヤフーショッピング) function yshopping_func( $atts, $content = null ) { // [yshopping]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=yshopping&keyword='.$keyword; } else { // それ以外の[rakuten]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=yshopping&keyword='.$keyword; } // カテゴリー指定 if (isset($category)) { $linkurl = $linkurl."&category=". $category; } // ソート指定 if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(ヤフーオークション) function yauction_func( $atts, $content = null ) { // [yauction]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=yauction&keyword='.$keyword; } else { // それ以外の[rakuten]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=yauction&keyword='.$keyword; } // カテゴリー指定 if (isset($category)) { $linkurl = $linkurl."&category=". $category; } // ソート指定 if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(アクセストレード) function actr_func( $atts, $content = null ) { // [actr]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=actr&keyword='.$keyword; } else { // それ以外の[rakuten]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=actr&keyword='.$keyword; } // カテゴリー指定 if (isset($category)) { $linkurl = $linkurl."&category=". $category; } // ソート指定 if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(Amazon) function amazon_vc_func( $atts, $content = null ) { // [actr]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'category' => null, 'sort_type' => null, ), $atts)); $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =""; if (isset($keyword)) { // 自由テキストリンクの場合 $keyword= urlencode($keyword); $linkurl = $vcpagepage.'pagetype=amazon_vc&keyword='.$keyword; } else { // それ以外の[rakuten]で挟まれたキーワードでの検索リンクを作成する場合 $keyword= urlencode($content); $linkurl = $vcpagepage.'pagetype=amazon_vc&keyword='.$keyword; } // カテゴリー指定 if (isset($category)) { $linkurl = $linkurl."&category=". $category; } // ソート指定 if (isset($sort_type)) { $linkurl = $linkurl."&sort_type=". $sort_type; } $linktext = ''.$content.''; // リンクとコンテンツを返す return $linktext; } // 商品検索リンク生成(じゃらん検索リンク生成) function jalanareasearch_func( $atts, $content = null ) { $linktext =""; $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $linktext =''; $linktext .=''; $linktext .=''; // コンテンツを返す return $linktext; } function saiyasune_func( $atts, $content = null ) { // データベースから設定情報を読み込む $vctoken= get_option('vc_search_token'); if ($vctoken=="") {$vctoken=VCTOKEN;} $vcpagepage= get_option('vc_search_page'); if ($vcpagepage=="") {$vcpagepage=VCPAGEPAGE;} $vc_yahoo_appid= get_option('vc_yahoo_appid'); if ($vc_yahoo_appid=="") {$vc_yahoo_appid=VC_YAHOO_APPID;} $lstoken= get_option('ls_search_token'); if ($lstoken=="") {$lstoken=LSTOKEN;} $jalantoken= get_option('jalan_search_token'); if ($jalantoken=="") {$jalantoken=JALANTOKEN;} $jalan_pid= get_option('jalan_pid'); if ($jalan_pid=="") {$jalan_pid=JALAN_PID;} $jalan_sid= get_option('jalan_sid'); if ($jalan_sid=="") {$jalan_sid=JALAN_SID;} $rakutentoken= get_option('rakuten_search_token'); if ($rakutentoken=="") {$rakutentoken=RAKUTENTOKEN;} $rakutenaffid= get_option('rakuten_affiliate_id'); if ($rakutentoken=="") {$rakutentoken=RAKUTENTOKEN;} $ysh_sid=get_option('ysh_sid'); if ($ysh_sid=="") {$ysh_sid=YSH_SID;} $ysh_pid=get_option('ysh_pid'); if ($ysh_pid=="") {$ysh_pid=YSH_PID;} $yauc_sid=get_option('yauc_sid'); if ($yauc_sid=="") {$yauc_sid=YAUC_SID;} $yauc_pid=get_option('yauc_pid'); if ($yauc_pid=="") {$yauc_pid=YAUC_PID;} $attoken=get_option('attoken'); if ($attoken=="") {$attoken=ATTOKEN;} $amzacckey=get_option('amzacckey'); if ($amzacckey==="") {$amzacckey==AMZACCKEY;} $amzseckey=get_option('amzseckey'); if ($amzacckey==="") {$amzacckey==AMZSECKEY;} $amzassid=get_option('amzassid'); if ($amzassid==="") {$amzassid==AMZASSID;} //検索条件 // [saiyasune]属性情報取得 extract(shortcode_atts(array( 'keyword' => null, 'ngword' => null, 'jancode' => null, ), $atts)); // ■検索条件 $minprice = "100"; $maxprice = "1000000"; $query = $keyword;// 検索クエリー $query4url = urlencode($query);// URLエンコード $jan = $jancode;// 商品コード指定 $rwsquery = $query;// 楽天検索用クエリー $rwsquery4url = rawurlencode($rwsquery);// URLエンコード $rwsngquery = $ngword;// 楽天検索用NGクエリー $rwsngquery4url = rawurlencode($rwsngquery);// URLエンコード // ■各社リクエストURL組立■ // YAHOO!ショッピングリクエストURL組み立て $ywsurl = "http://shopping.yahooapis.jp/ShoppingWebService/V1/itemSearch?appid=$vc_yahoo_appid&jan=$jan&sort=%2Bprice&hits=5&availability=1&price_from=$minprice&price_to=$maxprice&affiliate_from=2.0"; //$ywsurl = $ywsurl . "&affiliate_type=yid&affiliate_id=$token"; $ywsurl = $ywsurl . "&affiliate_type=vc&affiliate_id=http%3A%2F%2Fck.jp.ap.valuecommerce.com%2Fservlet%2Freferral%3Fsid%3D" . $ysh_sid . "%26pid%3D" . $ysh_pid . "%26vc_url%3D"; // 楽天リクエストURL組み立て $rwsurl = "http://api.rakuten.co.jp/rws/1.13/rest?developerId=$rakutentoken&affiliateId=$rakutenaffid&operation=ItemSearch&version=2009-02-03&keyword=$rwsquery4url&sort=%2BitemPrice&hits=5&availability=1&minPrice=$minprice&maxPrice=$maxprice&NGKeyword=$rwsngquery4url"; // linkshareリクエストURL組み立て $lsurl = "http://feed.linksynergy.com/productsearch?token=$lstoken&keyword=$query4url&max=5&sort=retailprice&sorttype=asc"; // &mid=3472,25051 // バリューコマースリクエストURL組み立て $vcurl = "http://webservice.valuecommerce.ne.jp/productdb/search?token=$vctoken&keyword=$query4url&sort_by=price&sort_order=asc&price_max=$maxprice&price_min=$minprice&result_per_page=5&ec_code=02t5n,0png4,0zttq,05f47,0j3hc,08x8b,07s9u,08fsg,bdrxs,0ha4k,0jcf6,03p68,03gpr,0wz95,09muc,bdufh,077ap,02spk,090a7,078nc"; // アクセストレードリクエストURL組み立て // http://interspace.typepad.jp/webservice/atws/index.html $aturl = "http://xml.accesstrade.net/at/ws.html?ws_type=searchgoods&ws_ver=1&ws_id=$attoken&search=$query4url&price_max=$maxprice&price_min=$minprice&row=5&sort1=3"; // AmazonリクエストURL組み立て $baseurl = 'http://ecs.amazonaws.jp/onca/xml'; $params = array(); $params['Service'] = 'AWSECommerceService'; $params['AWSAccessKeyId'] = $amzacckey; $params['Version'] = '2009-03-31'; $params['Operation'] = 'ItemSearch'; $params['SearchIndex'] = 'Blended'; $params['asin'] = "B001GQJJAE"; $params['AssociateTag'] = $amzassid; $params['Condition'] = 'New'; $params['ContentType'] = 'text/xml'; $params['ResponseGroup'] = 'Medium,Reviews,OfferSummary'; $params['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); // パラメータの順序を昇順に並び替えます ksort($params); $canonical_string = ''; foreach ($params as $k => $v) { $canonical_string .= '&'.urlencode_rfc3986($k).'='.urlencode_rfc3986($v); } $canonical_string = substr($canonical_string, 1); $parsed_url = parse_url($baseurl); $string_to_sign = "GET\n{$parsed_url['host']}\n{$parsed_url['path']}\n{$canonical_string}"; $signature = base64_encode(hash_hmac('sha256', $string_to_sign, $amzseckey, true)); $awsurl = $baseurl.'?'.$canonical_string.'&Signature='.urlencode_rfc3986($signature); // ヤフオクリクエストURL組み立て $yacurl = "http://auctions.yahooapis.jp/AuctionWebService/V1/Search?appid=$appid&query=$query4url&aucminprice=$minprice&aucmaxprice=$maxprice&sort=cbids&order=a"; // ■並列通信用マルチハンドルを用意■ $mh = curl_multi_init(); //通信先ごとにCurl Handleを作り、それを $mh にaddしていく(Y!ショッピング) $ch_ywsurl = curl_init($ywsurl); curl_setopt($ch_ywsurl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_ywsurl, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch_ywsurl); // 同様に(楽天市場) $ch_rwsurl = curl_init($rwsurl); curl_setopt($ch_rwsurl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_rwsurl, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch_rwsurl); // 同様に (リンクシェア) $ch_lsurl = curl_init($lsurl); curl_setopt($ch_lsurl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_lsurl, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch_lsurl); // 同様に (バリューコマース) $ch_vcurl = curl_init($vcurl); curl_setopt($ch_vcurl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_vcurl, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch_vcurl); // 同様に (アクセストレード) $ch_aturl = curl_init($aturl); curl_setopt($ch_aturl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_aturl, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch_aturl); // 同様に (Amazon.co.jp) $ch_awsurl = curl_init($awsurl); curl_setopt($ch_awsurl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_awsurl, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch_awsurl); // 同様に (ヤフオク) $ch_yacurl = curl_init($yacurl); curl_setopt($ch_yacurl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_yacurl, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch_yacurl); // せーので複数の通信を同時実行。whileで全て返ってくるのを待ちます do { curl_multi_exec($mh, $running); } while ( $running ); // 個々のXMLは、それぞれのCurl Handleを指定することで取得できる $xml_ywsurl = curl_multi_getcontent($ch_ywsurl); $xml_rwsurl = curl_multi_getcontent($ch_rwsurl); $xml_lsurl = curl_multi_getcontent($ch_lsurl); $xml_vcurl = curl_multi_getcontent($ch_vcurl); $xml_aturl = curl_multi_getcontent($ch_aturl); $xml_awsurl = curl_multi_getcontent($ch_awsurl); $xml_yacurl = curl_multi_getcontent($ch_yacurl); // 後始末 curl_multi_remove_handle($mh, $ch_ywsurl); curl_close($ch_ywsurl); curl_multi_remove_handle($mh, $ch_rwsurl); curl_close($ch_rwsurl); curl_multi_remove_handle($mh, $ch_lsurl); curl_close($ch_lsurl); curl_multi_remove_handle($mh, $ch_vcurl); curl_close($ch_vcurl); curl_multi_remove_handle($mh, $ch_aturl); curl_close($ch_aturl); curl_multi_remove_handle($mh, $ch_awsurl); curl_close($ch_awsurl); curl_multi_remove_handle($mh, $ch_yacurl); curl_close($ch_yacurl); curl_multi_close($mh); // ■並列通信ここまで■ // ■各社データを配列変数へ格納■ // ■YAHOO!ショッピングの処理■ $xml = simplexml_load_string ($xml_ywsurl); if ($xml["totalResultsReturned"] != 0) { $hits = $xml->Result->Hit; } foreach ($hits as $hit) { $itemname[] = h($hit->Name); $aflinkurl[] = h($hit->Url); if ($hit->Store->Id == "engei" or $hit->Store->Id == "dinos" or $hit->Store->Id == "fobcoop" or $hit->Store->Id == "ottojapan") { $imgurl[] = "c_img/linksakidegazo.gif"; } else { $imgurl[] = h($hit->Image->Medium); } $price[] = h($hit->Price); $description[] = h($hit->Description); $shopname[] = h($hit->Store->Name); $souryou[] = h($hit->Shipping->Name); $reviewnum[] = h($hit->Review->Count); $reviewavr[] = h($hit->Review->Rate); $reviewurl[] = h($hit->Review->Url); $faviconurl[] = "http://shopping.yahoo.co.jp/"; } // ■楽天市場の処理■ $rwsBuff = str_replace('header:Header', 'headerHeader', $xml_rwsurl);//置換 $rwsBuff = str_replace('itemSearch:ItemSearch', 'itemSearchItemSearch', $rwsBuff);//置換 $xml = simplexml_load_string ($rwsBuff);//置換されたXMLデータを処理 $hits = $xml->Body->itemSearchItemSearch->Items->Item; foreach ($hits as $hit) { $itemname[] = h($hit->itemName); $aflinkurl[] = h($hit->affiliateUrl); if (strlen($hit->mediumImageUrl)) { $imgurl[] = h($hit->mediumImageUrl); } else { $imgurl[] = "c_img/noimage.gif"; } $price[] = h($hit->itemPrice); $description[] = h($hit->itemCaption); $shopname[] = h($hit->shopName); //送料フラグ postageFlag 0:送料込 //1:送料別 if ($hit->postageFlag == 0) { $souryou[] = "送料無料"; } else { $souryou[] = "送料別"; } $reviewnum[] = h($hit->reviewCount); $reviewavr[] = h($hit->reviewAverage); $reviewurl[] = ""; $faviconurl[] = "http://www.rakuten.co.jp/"; } // ■リンクシェアの処理■ $xml = simplexml_load_string ($xml_lsurl); $hits = $xml->item; foreach ($hits as $hit) { if (!is_numeric(mb_strpos($hit->merchantname,"携帯"))) { $itemname[] = h($hit->productname); $aflinkurl[] = h($hit->linkurl); if (strlen($hit->imageurl)) { $imgurl[] = h($hit->imageurl); } else { $imgurl[] = "c_img/noimage.gif"; } $price[] = h($hit->price); $description[] = h($hit->description->short); $shopname[] = h($hit->merchantname); $souryou[] = ""; $reviewnum[] = ""; $reviewavr[] = ""; $reviewurl[] = ""; if ($hit->merchantname = "イトーヨーカドー ネット通販") { $faviconurl[] = "http://www.itoyokado.jp/"; } else { $faviconurl[] = h($hit->imageurl); } } } // ■バリューコマースの処理■ $vcBuff = str_replace('vc:', 'vc', $xml_vcurl); $xml = simplexml_load_string ($vcBuff); $hits = $xml->channel->item; foreach ($hits as $hit) { $itemname[] = h($hit->title); $aflinkurl[] = h($hit->link); // 画像URL取り出し $img = array(); foreach($hit->vcimage as $vcimg) { $img[]=$vcimg["url"]; } if (strlen($img[1])) { $imgurl[] = h($img[1]); } else { if (strlen($img[2])) { $imgurl[] = h($img[2]); } else { $imgurl[] = "c_img/noimage.gif"; } } $price[] = h($hit->vcprice); $description[] = h($hit->description); // ストア名とサブストア名が一緒ならサブストア名は使わない(ビッダーズとか) if (h($hit->vcmerchantName) == h($hit->vcsubStoreName)) { $shopname[] = h($hit->vcmerchantName); } else { $shopname[] = h($hit->vcmerchantName) . h($hit->vcsubStoreName); } $souryou[] = ""; $reviewnum[] = ""; $reviewavr[] = ""; $reviewurl[] = ""; $faviconurl[] = h($hit->guid); } // ■アクセストレードの処理■ $xml = simplexml_load_string ($xml_aturl); $hits = $xml->Goods; foreach ($hits as $hit) { $itemname[] = h($hit->GoodsName); $aflinkurl[] = h($hit->LinkCode); $img = array(); // 画像情報取り出し if (strlen($hit->ImageUrl)) { $imgurl[] = h($hit->ImageUrl); } else { $imgurl[] = "c_img/noimage.gif"; } $price[] = h($hit->Price); $description[] = h($hit->Explanation); $shopname[] = h($hit->ShopName); $souryou[] = ""; $reviewnum[] = ""; $reviewavr[] = ""; $reviewurl[] = ""; $faviconurl[] = h($hit->ImageUrl); } // ■Amazon.co.jpの処理■ $xml = simplexml_load_string ($xml_awsurl); $hits = $xml->Items->Item; foreach ($hits as $hit) { // amazonのみ値段の処理をここで追加 if ($hit->OfferSummary->LowestNewPrice->Amount > $minprice) { $itemname[] = h($hit->ItemAttributes->Title); $aflinkurl[] = h($hit->DetailPageURL); $imgurl[] = h($hit->MediumImage->URL); $price[] = h($hit->OfferSummary->LowestNewPrice->Amount); $description[] = h($hit->EditorialReviews->EditorialReview->Content); $shopname[] = "Amazon.co.jp"; $souryou[] = ""; $reviewnum[] = h($hit->CustomerReviews->TotalReviews); $reviewavr[] = h($hit->CustomerReviews->AverageRating); $reviewurl[] = ""; $faviconurl[] = "http://www.amazon.co.jp/"; } } // ■ヤフオクの処理■ $xml = simplexml_load_string ($xml_yacurl); $hits = $xml->item; $i=0; foreach ($hits as $hit) { $itemname[] = h($hit->title); $aflinkurl[] = "http://ck.jp.ap.valuecommerce.com/servlet/referral?sid=$yaucsid&pid=$yaucpid&vc_url=" . urlencode(h($hit->url)); $img = array(); // 画像情報取り出し if (strlen($hit->img)) { $imgurl[] = h($hit->img); } else { $imgurl[] = "c_img/noimage.gif"; } $pricebuff = h($hit->price); $pricebuff = str_replace(' 円', '', $pricebuff); $pricebuff = str_replace(',', '', $pricebuff); $price[] = intval($pricebuff); $description[] = "落札終了予定時間" . h($hit->endtime); $shopname[] = "Yahoo!オークション 出品者(ストア):" . h($hit->seller->id); $souryou[] = ""; $reviewnum[] = ""; $reviewavr[] = ""; $reviewurl[] = ""; $faviconurl[] = "http://auctions.yahoo.co.jp/jp/"; $i=$i+1; if ($i==5) {break;} } // 値段安い順番に並び替える(全部) asort($price); $i=0;// カウンタとして$iを使用。$iを0にセット $ret ="
"; foreach ($price as $key => $value) { $ret .= DrawPageItem($itemname[$key],$imgurl[$key],$aflinkurl[$key],$price[$key],$jancode[$key],$description[$key],$vcpvimg[$key],$guid[$key],$shopname[$key],$faviconurl[$key]); $i=$i+1;// カウンタの値をプラス1する if ($i==25) {break;} } $ret .="
"; // コンテンツを返す return $ret; } // 管理画面の作成 // 管理画面メニュー作成関数 function vc_search_menu() { add_options_page('VC Search Options', 'VC Search', 8, __FILE__, 'vc_search_options'); } // 管理画面描画 function vc_search_options() { // ポストされた値の入力チェックと書き込み if (isset($_POST['update_option'])) { check_admin_referer('vc_search-options'); update_option('vc_search_token', $_POST['vc_search_token']); update_option('vc_search_page', $_POST['vc_search_page']); update_option('vc_yahoo_appid', $_POST['vc_yahoo_appid']); update_option('ls_search_token', $_POST['ls_search_token']); update_option('jalan_search_token', $_POST['jalan_search_token']); update_option('jalan_pid', $_POST['jalan_pid']); update_option('jalan_sid', $_POST['jalan_sid']); update_option('rakuten_search_token', $_POST['rakuten_search_token']); update_option('rakuten_affiliate_id', $_POST['rakuten_affiliate_id']); update_option('ysh_sid', $_POST['ysh_sid']); update_option('ysh_pid', $_POST['ysh_pid']); update_option('yauc_sid', $_POST['yauc_sid']); update_option('yauc_pid', $_POST['yauc_pid']); update_option('attoken', $_POST['attoken']); update_option('amzacckey', $_POST['amzacckey']); update_option('amzseckey', $_POST['amzseckey']); update_option('amzassid', $_POST['amzassid']); update_option('custum_draw_on', $_POST['custum_draw_on']); update_option('custum_draw_template', $_POST['custum_draw_template']); //$this->upate_options(); ?>
API提供事業者やアフィリエイトASPから与えられたトークン、キー、パラメータなどを入力してください。