| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
|
|
6 |
Copyright (C) 2015~2024 Min-Jhin,Chen
|
|
|
7 |
|
|
|
8 |
This file is part of QBPWCF.
|
|
|
9 |
|
|
|
10 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
11 |
it under the terms of the GNU General Public License as published by
|
|
|
12 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22 |
|
|
|
23 |
*/
|
|
|
24 |
namespace qbpwcf;
|
|
|
25 |
|
|
|
26 |
/*
|
|
|
27 |
類別說明:
|
|
|
28 |
Meta/Fb應用的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
|
|
32 |
class fb{
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
#函式說明:
|
|
|
36 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
37 |
#回傳結果:
|
|
|
38 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
39 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
40 |
#$result["function"],當前執行的函式名稱.
|
|
|
41 |
#必填參數:
|
|
|
42 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
43 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
44 |
#參考資料:
|
|
|
45 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
46 |
*/
|
|
|
47 |
public function __call($method,$arguments){
|
|
|
48 |
|
|
|
49 |
#取得當前執行的函式
|
|
|
50 |
$result["function"]=__FUNCTION__;
|
|
|
51 |
|
|
|
52 |
#設置執行不正常
|
|
|
53 |
$result["status"]="false";
|
|
|
54 |
|
|
|
55 |
#設置執行錯誤
|
|
|
56 |
$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
57 |
|
|
|
58 |
#設置所丟入的參數
|
|
|
59 |
$result["error"][]=$arguments;
|
|
|
60 |
|
|
|
61 |
#回傳結果
|
|
|
62 |
return $result;
|
|
|
63 |
|
|
|
64 |
}#function __call end
|
|
|
65 |
|
|
|
66 |
/*
|
|
|
67 |
#函式說明:
|
|
|
68 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
69 |
#回傳結果:
|
|
|
70 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
71 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
72 |
#$result["function"],當前執行的函式名稱.
|
|
|
73 |
#必填參數:
|
|
|
74 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
75 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
76 |
#參考資料:
|
|
|
77 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
78 |
*/
|
|
|
79 |
public static function __callStatic($method,$arguments){
|
|
|
80 |
|
|
|
81 |
#取得當前執行的函式
|
|
|
82 |
$result["function"]=__FUNCTION__;
|
|
|
83 |
|
|
|
84 |
#設置執行不正常
|
|
|
85 |
$result["status"]="false";
|
|
|
86 |
|
|
|
87 |
#設置執行錯誤
|
|
|
88 |
$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
89 |
|
|
|
90 |
#設置所丟入的參數
|
|
|
91 |
$result["error"][]=$arguments;
|
|
|
92 |
|
|
|
93 |
#回傳結果
|
|
|
94 |
return $result;
|
|
|
95 |
|
|
|
96 |
}#function __callStatic end
|
|
|
97 |
|
|
|
98 |
/*
|
|
|
99 |
#涵式說明:
|
|
|
100 |
#建立匯入fb js sdk的語法
|
|
|
101 |
#回傳結果:
|
|
|
102 |
#$result,匯入js語法的語法
|
|
|
103 |
#必填參數:
|
|
|
104 |
#無
|
|
|
105 |
#可省略參數:
|
|
|
106 |
#無
|
|
|
107 |
*/
|
|
|
108 |
function importFbJsSdk(){
|
|
|
109 |
|
|
|
110 |
#匯入臉書js
|
|
|
111 |
$fbJsSdk="
|
|
|
112 |
<div id=\"fb-root\"></div>
|
|
|
113 |
<script>
|
|
|
114 |
(function(d, s, id)
|
|
|
115 |
{
|
|
|
116 |
var js, fjs = d.getElementsByTagName(s)[0];
|
|
|
117 |
if (d.getElementById(id)) return;
|
|
|
118 |
js = d.createElement(s); js.id = id;
|
|
|
119 |
js.src = '//connect.facebook.net/zh_TW/sdk.js#xfbml=1&version=v2.7&appId=269715116725149';
|
|
|
120 |
fjs.parentNode.insertBefore(js, fjs);
|
|
|
121 |
}(document,'script','facebook-jssdk'));
|
|
|
122 |
</script>
|
|
|
123 |
";
|
|
|
124 |
|
|
|
125 |
return $fbJsSdk;
|
|
|
126 |
|
|
|
127 |
}#function
|
|
|
128 |
|
|
|
129 |
#涵式說明:
|
|
|
130 |
#橫列的fb按贊與分享
|
|
|
131 |
#回傳的結果:
|
|
|
132 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
133 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
134 |
#$result["function"],當前執行的函式名稱.
|
|
|
135 |
#$result["content"],fb按贊語法.
|
|
|
136 |
#必填的參數:
|
|
|
137 |
#$conf["webYouLike"],字串,為想要按讚的網頁。
|
|
|
138 |
#$conf["webYouLike"]="";
|
|
|
139 |
#可省略的參數:
|
|
|
140 |
#$conf["width"],字串,為所佔頁面的寬度,可省略,預設為"100%"。
|
|
|
141 |
#$conf["width"]="";
|
|
|
142 |
#$conf["showFaces"],字串,是否顯示人物頭像,可省略,預設爲"true"
|
|
|
143 |
#$conf["showFaces"]="";
|
|
|
144 |
#$conf["action"],字串,是按讃"like"還是推薦"recommend",預設為"like"
|
|
|
145 |
#$conf["action"]="like";
|
|
|
146 |
#$conf["share"],字串,是否要開啟分享的功能,預設為"true"要開啟,"false"為不開啟.
|
|
|
147 |
#$conf["share"]="true";
|
|
|
148 |
#$conf["buttonSize"],字串,按鈕的大小,預設為"small",大一點則為"large".
|
|
|
149 |
#$conf["buttonSize"]="small";
|
|
|
150 |
#$conf["layout"],字串,呈現的版行,預設為"standard","box_count"為直的按鈕外沒有文字,"button_count",為橫的按鈕外沒有文字,"button"為僅顯示按鈕沒有計數與按鈕外的文字.
|
|
|
151 |
#參考資料:
|
|
|
152 |
#https://developers.facebook.com/docs/reference/plugins/like/
|
|
|
153 |
function LikeButton($conf){
|
|
|
154 |
|
|
|
155 |
#初始化要回傳的結果
|
|
|
156 |
$result=array();
|
|
|
157 |
|
|
|
158 |
#設置當其函數名稱
|
|
|
159 |
$result["function"]=__FUNCTION__;
|
|
|
160 |
|
|
|
161 |
#初始化按讃的fb語法
|
|
|
162 |
$result["content"]="";
|
|
|
163 |
|
|
|
164 |
#如果 $conf 不為陣列
|
|
|
165 |
if(gettype($conf)!="array"){
|
|
|
166 |
|
|
|
167 |
#設置執行失敗
|
|
|
168 |
$result["status"]="false";
|
|
|
169 |
|
|
|
170 |
#設置執行錯誤訊息
|
|
|
171 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
172 |
|
|
|
173 |
#如果傳入的參數為 null
|
|
|
174 |
if($conf==null){
|
|
|
175 |
|
|
|
176 |
#設置執行錯誤訊息
|
|
|
177 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
178 |
|
|
|
179 |
}#if end
|
|
|
180 |
|
|
|
181 |
#回傳結果
|
|
|
182 |
return $result;
|
|
|
183 |
|
|
|
184 |
}#if end
|
|
|
185 |
|
|
|
186 |
#函式說明:
|
|
|
187 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
188 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
189 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
190 |
#$result["function"],當前執行的函式名稱.
|
|
|
191 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
192 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
193 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
194 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
195 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
196 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
197 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
198 |
#必填寫的參數:
|
|
|
199 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
200 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
201 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
202 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("webYouLike");
|
|
|
203 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
204 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
205 |
#$conf["variableCheck::checkArguments"]f["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
206 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
207 |
#可以省略的參數:
|
|
|
208 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
209 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
210 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
211 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("send","width","showFaces","action","share","buttonSize","layout");
|
|
|
212 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
213 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string");
|
|
|
214 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
215 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true",null,"true","like","true","small","standard");
|
|
|
216 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
217 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
218 |
#參考資料來源:
|
|
|
219 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
220 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
221 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
222 |
|
|
|
223 |
#如果檢查參數失敗
|
|
|
224 |
if($checkArguments["status"]=="false"){
|
|
|
225 |
|
|
|
226 |
#設置執行失敗
|
|
|
227 |
$result["status"]="false";
|
|
|
228 |
|
|
|
229 |
#設置執行錯誤訊息
|
|
|
230 |
$result["error"]=$checkArguments;
|
|
|
231 |
|
|
|
232 |
#回傳結果
|
|
|
233 |
return $result;
|
|
|
234 |
|
|
|
235 |
}#if end
|
|
|
236 |
|
|
|
237 |
#涵式說明:
|
|
|
238 |
#建立匯入fb js sdk的語法
|
|
|
239 |
#回傳結果:
|
|
|
240 |
#$result,匯入js語法的語法
|
|
|
241 |
#必填參數:
|
|
|
242 |
#無
|
|
|
243 |
#可省略參數:
|
|
|
244 |
#無
|
|
|
245 |
$result["content"]=$result["content"].fb::importFbJsSdk();
|
|
|
246 |
|
|
|
247 |
#如果寬度有設置
|
|
|
248 |
if(isset($conf["width"])){
|
|
|
249 |
|
|
|
250 |
#設置寬度
|
|
|
251 |
$conf["width"]="data-width=\"".$conf["width"]."\"";
|
|
|
252 |
|
|
|
253 |
}#if end
|
|
|
254 |
|
|
|
255 |
#反之
|
|
|
256 |
else{
|
|
|
257 |
|
|
|
258 |
#設為空字串
|
|
|
259 |
$conf["width"]="";
|
|
|
260 |
|
|
|
261 |
}#esle end
|
|
|
262 |
|
|
|
263 |
#按讃的語法
|
|
|
264 |
$result["content"]=$result["content"]."<div class=\"fb-like\" ".$conf["width"]." data-href=\"".$conf["webYouLike"]."\" data-layout=\"".$conf["layout"]."\" data-action=\"".$conf["action"]."\" data-size=\"".$conf["buttonSize"]."\" data-show-faces=\"".$conf["showFaces"]."\" data-share=\"".$conf["share"]."\"></div>";
|
|
|
265 |
|
|
|
266 |
#設置執行正常
|
|
|
267 |
$result["status"]="true";
|
|
|
268 |
|
|
|
269 |
#回傳結果
|
|
|
270 |
return $result;
|
|
|
271 |
|
|
|
272 |
}#function LikeButton end
|
|
|
273 |
|
|
|
274 |
#涵式說明:
|
|
|
275 |
#直列的fb按贊與分享
|
|
|
276 |
#回傳的結果:
|
|
|
277 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
278 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
279 |
#$result["function"],當前執行的函式名稱.
|
|
|
280 |
#$result["content"],html5的fb按贊語法.
|
|
|
281 |
#必填的參數:
|
|
|
282 |
#$conf["webYouLike"],字串,為想要按讚的網頁。
|
|
|
283 |
#$conf["webYouLike"]="";
|
|
|
284 |
#可省略的參數:
|
|
|
285 |
#$conf["width"],字串,為所佔頁面的寬度,可省略,預設為"100%"。
|
|
|
286 |
#$conf["width"]="";
|
|
|
287 |
#$conf["showFaces"],字串,是否顯示人物頭像,可省略,預設爲"true"
|
|
|
288 |
#$conf["showFaces"]="";
|
|
|
289 |
#$conf["type"],字串排版類型,預設為"button_count"亦即橫的,"box_count"則為直的.
|
|
|
290 |
#$conf["type"]="button_count";
|
|
|
291 |
#$conf["action"],字串,是按讃"like"還是推薦"recommend",預設為"like"
|
|
|
292 |
#$conf["action"]="like";
|
|
|
293 |
#參考資料:
|
|
|
294 |
#https://developers.facebook.com/docs/reference/plugins/like/
|
|
|
295 |
function LikeButtonForMobile($conf){
|
|
|
296 |
|
|
|
297 |
#初始化要回傳的結果
|
|
|
298 |
$result=array();
|
|
|
299 |
|
|
|
300 |
#設置當其函數名稱
|
|
|
301 |
$result["function"]=__FUNCTION__;
|
|
|
302 |
|
|
|
303 |
#初始化按讃的fb語法
|
|
|
304 |
$result["content"]="";
|
|
|
305 |
|
|
|
306 |
#如果 $conf 不為陣列
|
|
|
307 |
if(gettype($conf)!="array"){
|
|
|
308 |
|
|
|
309 |
#設置執行失敗
|
|
|
310 |
$result["status"]="false";
|
|
|
311 |
|
|
|
312 |
#設置執行錯誤訊息
|
|
|
313 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
314 |
|
|
|
315 |
#如果傳入的參數為 null
|
|
|
316 |
if($conf==null){
|
|
|
317 |
|
|
|
318 |
#設置執行錯誤訊息
|
|
|
319 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
320 |
|
|
|
321 |
}#if end
|
|
|
322 |
|
|
|
323 |
#回傳結果
|
|
|
324 |
return $result;
|
|
|
325 |
|
|
|
326 |
}#if end
|
|
|
327 |
|
|
|
328 |
#函式說明:
|
|
|
329 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
330 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
331 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
332 |
#$result["function"],當前執行的函式名稱.
|
|
|
333 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
334 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
335 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
336 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
337 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
338 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
339 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
340 |
#必填寫的參數:
|
|
|
341 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
342 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
343 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
344 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("webYouLike");
|
|
|
345 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
346 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
347 |
#$conf["variableCheck::checkArguments"]f["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
348 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
349 |
#可以省略的參數:
|
|
|
350 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
351 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
352 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
353 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("send","width","showFaces","type","action");
|
|
|
354 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
355 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string");
|
|
|
356 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
357 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true",null,"true","button_count","like");
|
|
|
358 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
359 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
360 |
#參考資料來源:
|
|
|
361 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
362 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
363 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
364 |
|
|
|
365 |
#如果檢查參數失敗
|
|
|
366 |
if($checkArguments["status"]=="false"){
|
|
|
367 |
|
|
|
368 |
#設置執行失敗
|
|
|
369 |
$result["status"]="false";
|
|
|
370 |
|
|
|
371 |
#設置執行錯誤訊息
|
|
|
372 |
$result["error"]=$checkArguments;
|
|
|
373 |
|
|
|
374 |
#回傳結果
|
|
|
375 |
return $result;
|
|
|
376 |
|
|
|
377 |
}#if end
|
|
|
378 |
|
|
|
379 |
#匯入fb sdk
|
|
|
380 |
#涵式說明:
|
|
|
381 |
#建立匯入fb js sdk的語法
|
|
|
382 |
#回傳結果:
|
|
|
383 |
#$result,匯入js語法的語法
|
|
|
384 |
#必填參數:
|
|
|
385 |
#無
|
|
|
386 |
#可省略參數:
|
|
|
387 |
#無
|
|
|
388 |
$result["content"]=$result["content"].fb::importFbJsSdk();
|
|
|
389 |
|
|
|
390 |
#如果寬度有設置
|
|
|
391 |
if(isset($conf["width"])){
|
|
|
392 |
|
|
|
393 |
#設置寬度
|
|
|
394 |
$conf["width"]="data-width=\"".$conf["width"]."\"";
|
|
|
395 |
|
|
|
396 |
}#if end
|
|
|
397 |
|
|
|
398 |
#反之
|
|
|
399 |
else{
|
|
|
400 |
|
|
|
401 |
#設為空字串
|
|
|
402 |
$conf["width"]="";
|
|
|
403 |
|
|
|
404 |
}#esle end
|
|
|
405 |
|
|
|
406 |
#按讃的語法
|
|
|
407 |
$result["content"]=$result["content"]." <div class=\"fb-like\" "."data-href=\"".$conf["webYouLike"]."\" data-layout=\"".$conf["type"]."\" data-action=\"".$conf["action"]."\" data-share=\"true\" "."data-send=\"".$conf["send"]."\" ".$conf["width"]." data-show-faces=\"".$conf["showFaces"]."\" "."></div>";
|
|
|
408 |
|
|
|
409 |
#設置執行正常
|
|
|
410 |
$result["status"]="true";
|
|
|
411 |
|
|
|
412 |
#回傳結果
|
|
|
413 |
return $result;
|
|
|
414 |
|
|
|
415 |
}#function LikeButtonForMobile end
|
|
|
416 |
|
|
|
417 |
/*
|
|
|
418 |
#涵式說明:
|
|
|
419 |
#fb傳送含特定網址的訊息給別人
|
|
|
420 |
#回傳的結果:
|
|
|
421 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
422 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
423 |
#$result["function"],當前執行的函式名稱.
|
|
|
424 |
#$result["content"],語法.
|
|
|
425 |
#必填的參數:
|
|
|
426 |
#$conf["webYouSend"],字串,為想要按讚的網頁。
|
|
|
427 |
$conf["webYouSend"]="";
|
|
|
428 |
#參考資料:
|
|
|
429 |
#https://developers.facebook.com/docs/plugins/send-button
|
|
|
430 |
*/
|
|
|
431 |
function sendLink($conf){
|
|
|
432 |
|
|
|
433 |
#初始化要回傳的結果
|
|
|
434 |
$result=array();
|
|
|
435 |
|
|
|
436 |
#設置當其函數名稱
|
|
|
437 |
$result["function"]=__FUNCTION__;
|
|
|
438 |
|
|
|
439 |
#初始化send的fb語法
|
|
|
440 |
$result["content"]="";
|
|
|
441 |
|
|
|
442 |
#如果 $conf 不為陣列
|
|
|
443 |
if(gettype($conf)!="array"){
|
|
|
444 |
|
|
|
445 |
#設置執行失敗
|
|
|
446 |
$result["status"]="false";
|
|
|
447 |
|
|
|
448 |
#設置執行錯誤訊息
|
|
|
449 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
450 |
|
|
|
451 |
#如果傳入的參數為 null
|
|
|
452 |
if($conf==null){
|
|
|
453 |
|
|
|
454 |
#設置執行錯誤訊息
|
|
|
455 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
456 |
|
|
|
457 |
}#if end
|
|
|
458 |
|
|
|
459 |
#回傳結果
|
|
|
460 |
return $result;
|
|
|
461 |
|
|
|
462 |
}#if end
|
|
|
463 |
|
|
|
464 |
#函式說明:
|
|
|
465 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
466 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
467 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
468 |
#$result["function"],當前執行的函式名稱.
|
|
|
469 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
470 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
471 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
472 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
473 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
474 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
475 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
476 |
#必填寫的參數:
|
|
|
477 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
478 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
479 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
480 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("webYouSend");
|
|
|
481 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
482 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
483 |
#$conf["variableCheck::checkArguments"]f["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
484 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
485 |
#可以省略的參數:
|
|
|
486 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
487 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
488 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
489 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("send","width","showFaces","type","action");
|
|
|
490 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
491 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string");
|
|
|
492 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
493 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true","100%","true","button_count","like");
|
|
|
494 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
495 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
496 |
#參考資料來源:
|
|
|
497 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
498 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
499 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
500 |
|
|
|
501 |
#如果檢查參數失敗
|
|
|
502 |
if($checkArguments["status"]=="false"){
|
|
|
503 |
|
|
|
504 |
#設置執行失敗
|
|
|
505 |
$result["status"]="false";
|
|
|
506 |
|
|
|
507 |
#設置執行錯誤訊息
|
|
|
508 |
$result["error"]=$checkArguments;
|
|
|
509 |
|
|
|
510 |
#回傳結果
|
|
|
511 |
return $result;
|
|
|
512 |
|
|
|
513 |
}#if end
|
|
|
514 |
|
|
|
515 |
#匯入fb sdk
|
|
|
516 |
#涵式說明:
|
|
|
517 |
#建立匯入fb js sdk的語法
|
|
|
518 |
#回傳結果:
|
|
|
519 |
#$result,匯入js語法的語法
|
|
|
520 |
#必填參數:
|
|
|
521 |
#無
|
|
|
522 |
#可省略參數:
|
|
|
523 |
#無
|
|
|
524 |
$result["content"]=$result["content"].fb::importFbJsSdk();
|
|
|
525 |
|
|
|
526 |
#設置要傳送的網址
|
|
|
527 |
$result["content"]=$result["content"]."<div class=\"fb-send\" data-href=\"".$conf["webYouSend"]."\"></div>";
|
|
|
528 |
|
|
|
529 |
#設置執行正常
|
|
|
530 |
$result["status"]="true";
|
|
|
531 |
|
|
|
532 |
#回傳結果
|
|
|
533 |
return $result;
|
|
|
534 |
|
|
|
535 |
}#function sendLink end
|
|
|
536 |
|
|
|
537 |
/*
|
|
|
538 |
#函數說明:
|
|
|
539 |
#嵌入臉書的粉絲頁面.
|
|
|
540 |
#必填參數:
|
|
|
541 |
#$conf["pageUrl"],字串,粉絲專頁的網址.
|
|
|
542 |
$conf["pageUrl"]="";
|
|
|
543 |
#可省略參數:
|
|
|
544 |
#$conf["pageName"],字串要顯示的粉絲頁名稱,預設為"https://www.facebook.com/"後面的內容
|
|
|
545 |
#$conf["pageName"]="";
|
|
|
546 |
#$conf["smallHeader"],字串,是否要使用小型的頁首,預設為"false"不使用,"true"代表要使用.
|
|
|
547 |
#$conf["smallHeader"]="";
|
|
|
548 |
#$conf["hideCover"],字串,是否要隱藏頁首,預設為"false",不隱藏,"true"代表要隱藏.
|
|
|
549 |
#$conf["hideCover"]="";
|
|
|
550 |
#$conf["showFace"],字串,是否要顯示人物的大頭貼,預設為"true"要顯示,"false"代表不顯示.
|
|
|
551 |
#$conf["showFace"]="";
|
|
|
552 |
#$conf["class"],字串陣列,要套用的css類別.
|
|
|
553 |
#$conf["class"]=array();
|
|
|
554 |
#參考資料:
|
|
|
555 |
#page-plugin=>https://developers.facebook.com/docs/plugins/page-plugin
|
|
|
556 |
*/
|
|
|
557 |
function embedFeeds(&$conf){
|
|
|
558 |
|
|
|
559 |
#初始化要回傳的結果
|
|
|
560 |
$result=array();
|
|
|
561 |
|
|
|
562 |
#取得當前執行的函數名稱
|
|
|
563 |
$result["function"]=__FUNCTION__;
|
|
|
564 |
|
|
|
565 |
#如果沒有參數
|
|
|
566 |
if(func_num_args()==0){
|
|
|
567 |
|
|
|
568 |
#設置執行失敗
|
|
|
569 |
$result["status"]="false";
|
|
|
570 |
|
|
|
571 |
#設置執行錯誤訊息
|
|
|
572 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
573 |
|
|
|
574 |
#回傳結果
|
|
|
575 |
return $result;
|
|
|
576 |
|
|
|
577 |
}#if end
|
|
|
578 |
|
|
|
579 |
#取得參數
|
|
|
580 |
$result["argu"]=$conf;
|
|
|
581 |
|
|
|
582 |
#如果 $conf 不為陣列
|
|
|
583 |
if(gettype($conf)!=="array"){
|
|
|
584 |
|
|
|
585 |
#設置執行失敗
|
|
|
586 |
$result["status"]="false";
|
|
|
587 |
|
|
|
588 |
#設置執行錯誤訊息
|
|
|
589 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
590 |
|
|
|
591 |
#如果傳入的參數為 null
|
|
|
592 |
if($conf===null){
|
|
|
593 |
|
|
|
594 |
#設置執行錯誤訊息
|
|
|
595 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
596 |
|
|
|
597 |
}#if end
|
|
|
598 |
|
|
|
599 |
#回傳結果
|
|
|
600 |
return $result;
|
|
|
601 |
|
|
|
602 |
}#if end
|
|
|
603 |
|
|
|
604 |
#檢查參數
|
|
|
605 |
#函式說明:
|
|
|
606 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
607 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
608 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
609 |
#$result["function"],當前執行的函式名稱.
|
|
|
610 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
611 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
612 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
613 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
614 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
615 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
616 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
617 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
618 |
#必填寫的參數:
|
|
|
619 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
620 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
621 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
622 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("pageUrl");
|
|
|
623 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
624 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
625 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
626 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
627 |
#可以省略的參數:
|
|
|
628 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
629 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
630 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
631 |
#$conf["canNotBeEmpty"]=array();
|
|
|
632 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
633 |
#$conf["canBeEmpty"]=array();
|
|
|
634 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
635 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("smallHeader","hideCover","showFace","class","pageName");
|
|
|
636 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
637 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("smallHeader","hideCover","showFace","class","pageName");;
|
|
|
638 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
639 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","array","string");
|
|
|
640 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
641 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false","true",null,null);
|
|
|
642 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
643 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
644 |
#參考資料來源:
|
|
|
645 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
646 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
647 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
648 |
|
|
|
649 |
#如果檢查參數失敗
|
|
|
650 |
if($checkArguments["status"]==="false"){
|
|
|
651 |
|
|
|
652 |
#設置執行失敗
|
|
|
653 |
$result["status"]="false";
|
|
|
654 |
|
|
|
655 |
#設置執行錯誤訊息
|
|
|
656 |
$result["error"]=$checkArguments;
|
|
|
657 |
|
|
|
658 |
#回傳結果
|
|
|
659 |
return $result;
|
|
|
660 |
|
|
|
661 |
}#if end
|
|
|
662 |
|
|
|
663 |
#如果檢查參數不通過
|
|
|
664 |
if($checkArguments["passed"]==="false"){
|
|
|
665 |
|
|
|
666 |
#設置執行失敗
|
|
|
667 |
$result["status"]="false";
|
|
|
668 |
|
|
|
669 |
#設置執行錯誤訊息
|
|
|
670 |
$result["error"]=$checkArguments;
|
|
|
671 |
|
|
|
672 |
#回傳結果
|
|
|
673 |
return $result;
|
|
|
674 |
|
|
|
675 |
}#if end
|
|
|
676 |
|
|
|
677 |
#如果 $conf["pageName"] 不存在
|
|
|
678 |
if(!isset($conf["pageName"])){
|
|
|
679 |
|
|
|
680 |
#取得踢除 $conf["pageUrl"] 的 https://www.facebook.com/ 的內容
|
|
|
681 |
#函式說明:
|
|
|
682 |
#將字串特定關鍵字與其前面的內容剔除
|
|
|
683 |
#回傳結果:
|
|
|
684 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
685 |
#$result["error"],錯誤訊息陣列.
|
|
|
686 |
#$result["warning"],警告訊息鎮列.
|
|
|
687 |
#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
|
|
|
688 |
#$result["function"],當前執行的函數名稱.
|
|
|
689 |
#$result["oriStr"],要處理的原始字串內容.
|
|
|
690 |
#$result["content"],處理好的的字串內容.
|
|
|
691 |
#必填的參數:
|
|
|
692 |
$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$conf["pageUrl"];#要處理的字串.
|
|
|
693 |
$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="https://www.facebook.com/";#特定字串.
|
|
|
694 |
$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
|
|
|
695 |
unset($conf["stringProcess::delStrBeforeKeyWord"]);
|
|
|
696 |
|
|
|
697 |
#如果處理字串失敗
|
|
|
698 |
if($delStrBeforeKeyWord["status"]==="false"){
|
|
|
699 |
|
|
|
700 |
#設置執行失敗
|
|
|
701 |
$result["status"]="false";
|
|
|
702 |
|
|
|
703 |
#設置執行錯誤訊息
|
|
|
704 |
$result["error"]=$delStrBeforeKeyWord;
|
|
|
705 |
|
|
|
706 |
#回傳結果
|
|
|
707 |
return $result;
|
|
|
708 |
|
|
|
709 |
}#if end
|
|
|
710 |
|
|
|
711 |
#如果前戳字串不存在
|
|
|
712 |
if($delStrBeforeKeyWord["founded"]==="false"){
|
|
|
713 |
|
|
|
714 |
#設置執行失敗
|
|
|
715 |
$result["status"]="false";
|
|
|
716 |
|
|
|
717 |
#設置執行錯誤訊息
|
|
|
718 |
$result["error"]=$delStrBeforeKeyWord;
|
|
|
719 |
|
|
|
720 |
#設置錯誤訊息
|
|
|
721 |
$result["error"][]="粉絲頁前戳字串「https://www.facebook.com」不存在";
|
|
|
722 |
|
|
|
723 |
#回傳結果
|
|
|
724 |
return $result;
|
|
|
725 |
|
|
|
726 |
}#if end
|
|
|
727 |
|
|
|
728 |
#取得粉絲團的名稱
|
|
|
729 |
$conf["pageName"]=$delStrBeforeKeyWord["content"];
|
|
|
730 |
|
|
|
731 |
#如果粉絲頁面含有「/」,則要進行處理
|
|
|
732 |
#函式說明:
|
|
|
733 |
#將字串特定關鍵字與其後面的內容剔除
|
|
|
734 |
#回傳結果:
|
|
|
735 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
736 |
#$result["error"],錯誤訊息陣列.
|
|
|
737 |
#$result["warning"],警告訊息鎮列.
|
|
|
738 |
#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
|
|
|
739 |
#$result["function"],當前執行的函數名稱.
|
|
|
740 |
#$result["oriStr"],要處理的原始字串內容.
|
|
|
741 |
#$result["content"],處理好的的字串內容.
|
|
|
742 |
#必填的參數:
|
|
|
743 |
$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$conf["pageName"];#要處理的字串.
|
|
|
744 |
$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="/";#特定字串.
|
|
|
745 |
$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
|
|
|
746 |
unset($conf["stringProcess::delStrAfterKeyWord"]);
|
|
|
747 |
|
|
|
748 |
#如果處理字串失敗
|
|
|
749 |
if($delStrAfterKeyWord["status"]==="false"){
|
|
|
750 |
|
|
|
751 |
#設置執行失敗
|
|
|
752 |
$result["status"]="false";
|
|
|
753 |
|
|
|
754 |
#設置執行錯誤訊息
|
|
|
755 |
$result["error"]=$delStrBeforeKeyWord;
|
|
|
756 |
|
|
|
757 |
#回傳結果
|
|
|
758 |
return $result;
|
|
|
759 |
|
|
|
760 |
}#if end
|
|
|
761 |
|
|
|
762 |
#取得粉絲團的名稱
|
|
|
763 |
$conf["pageName"]=$delStrAfterKeyWord["content"];
|
|
|
764 |
|
|
|
765 |
}#if end
|
|
|
766 |
|
|
|
767 |
#匯入fb js sdk
|
|
|
768 |
$fbJsSdk=fb::importFbJsSdk();
|
|
|
769 |
|
|
|
770 |
#放置臉書塗鴉牆
|
|
|
771 |
$feeds="
|
|
|
772 |
<div
|
|
|
773 |
class=\"fb-page\"
|
|
|
774 |
data-href=\"".$conf["pageUrl"]."\"
|
|
|
775 |
data-tabs=\"timeline\"
|
|
|
776 |
data-small-header=\"".$conf["smallHeader"]."\"
|
|
|
777 |
data-adapt-container-width=\"true\"
|
|
|
778 |
data-hide-cover=\"".$conf["hideCover"]."\"
|
|
|
779 |
data-show-facepile=\"".$conf["showFace"]."\"
|
|
|
780 |
>
|
|
|
781 |
<blockquote
|
|
|
782 |
cite=\"https://www.facebook.com/QBPWCF/\"
|
|
|
783 |
class=\"fb-xfbml-parse-ignore\"
|
|
|
784 |
>
|
|
|
785 |
<a
|
|
|
786 |
href=\"".$conf["pageUrl"]."\"
|
|
|
787 |
>
|
|
|
788 |
".$conf["pageName"]."
|
|
|
789 |
</a>
|
|
|
790 |
</blockquote>
|
|
|
791 |
</div>
|
|
|
792 |
";
|
|
|
793 |
|
|
|
794 |
#設置要回傳的語法
|
|
|
795 |
$result["content"]=$fbJsSdk."\r\n".$feeds;
|
|
|
796 |
|
|
|
797 |
#設置執行正常
|
|
|
798 |
$result["status"]="true";
|
|
|
799 |
|
|
|
800 |
#回傳結果
|
|
|
801 |
return $result;
|
|
|
802 |
|
|
|
803 |
}#functino embedFeeds end
|
|
|
804 |
|
|
|
805 |
}#class fb end
|
|
|
806 |
|
|
|
807 |
?>
|