Friday, February 17, 2012

Facebook 檢查是否有點擊讚按鈕 (Likes)

$appId = '1234567890'; // Facebook App Id
$res = $this->facebook->api('/me/likes/' . $appId);
回傳值:
{
  "data": [
    {
      "name": "應用程式名稱",
      "category": "Application",
      "id": "1234567890",
      "created_time": "2012-02-17T07:54:54+0000"
    }
  ],
  "paging": {
    "next": ""
  }
}
use FQL:
$appId = 1234567890;

$query = array(
  'likes' => "SELECT uid, page_id, type, profile_section, 
                     created_time FROM page_fan
              WHERE uid = me() AND 
                    page_id = "' . $appId . '",
);

/**
 * 回傳值
 * $response = array(
 *   array(
 *     'name' => 'likes',
 *     'fql_result_set' => array(
 *       array(
 *         "created_time" => "1329468255",
 *         "page_id" => "1234567890",
 *         "profile_section" => "other",
 *         "type" => "APP",
 *         "uid" => "100000119629520"
 *       )
 *     )
 *   )
 * );
 */
$responses = $this->facebook->api(
  array(
    'method' => 'fql.multiquery',
    'queries' => $query
  )
);
Facebook Javascript Like button click event:
FB.Event.subscribe('edge.create',
  function(response) {
    //alert('You liked the URL: ' + response);
  }
);

Tuesday, January 24, 2012

偵測是否要取得最新版本的 Flash 檔案

Flash loader 在開始取得檔案前, 先用 xxx?v=28172364656 的方式取得一個設定檔, 該設定檔帶的 v={microtime} 其時間單位為 load 檔時的時間郵戳, 以確保該設定檔每次都是 load 到最新的, 再將要取得的檔案列表放在該設定檔內, 每個檔案都用 yyy?v=123458 的方式做版本控制, 這樣應該可以讓 Flash loader 隨時都能取得最新的檔案

Monday, January 02, 2012

Doctrine2 ORM add query result cache and delete cache

// add query result cache
$query = $this->createQueryBuilder('i')
              ->where('i.delete = false')
              ->getQuery();
$query->useResultCache(true, 3600, 'allItems');
$items = $query->getArrayResult();

// delete cache
$em->getConfiguration()
   ->getResultCacheImpl()->delete('allItems');

Saturday, December 17, 2011

Develop Symfony2 with Eclipse

1. Download Eclipse IDE for Java EE Developers

2. Extract the archive file to where you want to install Eclipse.

3. Open Eclipse, Go to Help->Install New Software...

4. Add Symfony-2-Eclipse-Plugin repository: http://pulse00.github.com/Symfony-2-Eclipse-Plugin/

5. Install All of them. (PDT Extensions, PHP Development Tools, Symfony, YEdit)

6. Add Eclipse Color Theme plugins repository: http://eclipse-color-theme.github.com/update

7. Install Eclipse Color Theme

8. Download Eclipse Symfony2 theme

9. Go to Window->Preferences->General->Appearance->Color Theme , and install the Symfony2 theme.

10. ALL DONE! ENJOY Symfony2!

ex1. Go to PHP->Code Style->Formatter(PDT Tooles) Change Active profile to "Symfony [built in]"

ex2. Edit theme color in Twig: Normal, String

ex3. Edit theme color in YEdit: Scalars, Documents, Default

Wednesday, December 07, 2011

Tuesday, November 08, 2011

Javascript and PHP AES encrypt decrypt library

This is a Javascript AES encrypt decrypt library
AES Advanced Encryption Standard

And this is a PHP AES encrypt decrypt library
AES in PHP