This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapifunc.php
92 lines (75 loc) · 3.59 KB
/
apifunc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
WebサービスAPIアプリ用functionファイル Ver.1.2(2010/03/26)
by WebサービスAPI's wakcey http://web-service-api.jp/
■使い方
WebサービスAPIを利用したアプリケーションを開発するときに共通して利用しそうな関数をこちらでまとめています。
それぞれの関数を呼び出します。
*/
/* Copyright 2009-2010 wackey
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// ■htmlspecialchars:HTMLを無効化します
function h($str)
{
return htmlspecialchars($str, ENT_QUOTES);
}
// ■Amazon APIリクエスト用:リクエストURL組み立てするときに使用
function urlencode_rfc3986($str)
{
return str_replace('%7E', '~', rawurlencode($str));
}
// ■セレクトメニュー作成:<select>タグによるメニュー描画、パラメータから選択されているものを選択状態にする。
// select name、select option配列、選択、オプション
function DrawSelectMenu($name, $source_arr, $select_value, $option) {
echo "<select name=\"$name\">$option";
foreach($source_arr as $key => $value) {
echo "<option value=\"$key\"";
if ($key == $select_value) {
echo " selected";
}
echo ">$value</option>";
}
echo "</select>";
}
// ■ナビゲーションリンク作成:現在ページ数、総ページ数、検索条件パラメータ、検索結果数を受け取りリンクを出力
function pagenavilink($genzai_page, $totalpage, $params, $resultcount) {
if (!$resultcount==0) { // 検索結果があれば(0件じゃなければ)
echo "検索結果" . number_format($resultcount) . "件<br />";// 検索結果数表示
if(!isset($genzai_page)) {// もし現在のページ数が設定されてないなら
$genzai_page = 1;
}
if($genzai_page > 1) {// もし現在のページ数が「1」より大きい、つまり2以上であれば前のページに戻るリンクを書く
$page = $genzai_page - 1;
echo "<a href=\"" . $params . "&page=$page\">前へ</a> ";
}
if($genzai_page < $totalpage) {// もし現在のページ数が総ページ数より小さいのであれば次のページに進むリンクを書く
$page = $genzai_page + 1;
echo "<a href=\"" . $params . "&page=$page\">次へ</a>";
}
}// if !$resultcount
//検索結果がゼロの時は何もしない「検索結果0件」という文字も表示しない
}
// ■じゃらんアフィリエイトリンク作成関数PC用(リンクシェア)
function jalan_pc_aflink($jalanurl,$lstoken) {
$url="http://feed.linksynergy.com/createcustomlink.shtml?token=$lstoken&mid=24834&murl=$jalanurl";
$link = file_get_contents($url);
return $link;
}
// ■じゃらんアフィリエイトリンク作成関数ケータイ用(リンクシェア)
function jalan_ktai_aflink($jalanurl) {
$url="http://feed.linksynergy.com/createcustomlink.shtml?token=$lstoken&mid=24835&murl=$jalanurl";
$link = file_get_contents($url);
return $link;
}
?>