2012年11月15日 星期四

快速取得facebook粉絲團資料

粉絲團
https://www.facebook.com/vieshow

graph
http://graph.facebook.com/vieshow

就這樣

2012年8月20日 星期一

php float 處理

處理facebook id時因為數字過大會轉成科學計數方式呈現1.111E+12之類的

處理方式
修改 php.ini
precision    =  24

或在 code裡

ini_set('precision',24);

2012年6月18日 星期一

建立透明png

建立透明png
 $im = imagecreatetruecolor($width,$height);
 imagealphablending($im,true);
 $transparent = imagecolorallocatealpha($im,0,0,0,127);      
 imagefill($im,0,0,$transparent);     
 imagesavealpha($im,true);

 header("Content-Type: image/png");
 imagepng($im);
 imagedestroy($im);

2012年6月14日 星期四

jquery判斷瀏覽器

參考 http://api.jquery.com/jQuery.browser/
判斷瀏覽器可以很快速方便
if ( $.browser.msie ){
  alert('IE跑不快');
}

2012年6月7日 星期四

FQL console 工具

使用Facebook FQL API總算有方便官方工具
https://developers.facebook.com/tools/explorer/
1. 右上方的Application選好要測試的app
2. 點選左邊的 FQL Query
3. 輸入框裡輸入 select name from user where uid=me()
4. 按下右邊的Submit
即可看到回傳的資料

{
  "data": [
    {
      "name": "Bruce Tseng"
    }
  ]
}

foursquare venues platform 地標資料

foursquare venues platform 提供不需認證即可取得資料的API
每小時可連線五千次
https://developer.foursquare.com/overview/venues
範例程式碼

<?php
$query = 'https://api.foursquare.com/v2/venues/search?ll='.$lat.','.$long.'&client_id='.$foursquare_app_id.'&client_secret='.$foursquare_app_secret.'&v='.date('Ymd');
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $query);
$query_res = curl_exec($ch);
curl_close($ch);
$res = json_decode($query_res);
var_dump($res);

?>

2012年5月21日 星期一

regular expression 正規表示法 判斷中韓日文

regular expression 正規表示法
判斷中韓日文
\u4e00-\u9fa5 (中文)
\x3130-\x318F (韓文)
\xAC00-\xD7A3 (韓文)
\u0800-\u4e00 (日文)
if (preg_match("/[\u4e00-\u9fa5]/", $str)){
 echo '是中文';
}
參考: http://www.wilf.cn/post/php-match-chinese-str.html