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);

?>