2011年10月4日 星期二

google+ PHP API

這篇算是上一篇的延續,
google+ 有提供官方 php api

下載後修改 index.php

$client->setApplicationName("Google+ Application Name");
$client->setClientId('your id');
$client->setClientSecret('your secret');
$client->setRedirectUri('https://your.url');
$client->setDeveloperKey('your key'); // Simple API Access

即可取得 access token,差別在於
這邊取得 token 的方式為 server-side flow
response_type=code

之前的方式為 client-side flow
response_type=token



2011年9月30日 星期五

google plus api note


1. 準備
先去 google console
開啟 Google+ api service (Courtesy limit: 1,000 queries/day)
再來去 API Access create client ID and simple API Access
勾選 Application type and Redirect URI 填一填
Redirect URI:Google should redirect the browser after the user allows (or denies) the authorization request(簡單講就是授權完要導去的頁面)

2. API 流程
OAuth2->user 登入/同意取得權限->導回 redirect_url 並取得 access_token ->API Call

2011年9月26日 星期一

event hijacking - flash gaia framework

gaia event hijacking 可是相當博大精深的呀~~
首先要知道有哪些 gaia flow events 可用
beforeGoto
afterGoto
beforeTransitionOut
afterTransitionOut
beforePreload
afterPreload
beforeTransitionIn
afterTransitionIn
afterComplete(no hijacking)

假設要在 transitionIn 之前做一些事,
先宣告
private var releaseGaia:Function;
// in constructor
releaseGaia = Gaia.api.beforeTransitionIn(onBeforeTransitionIn,true);

private function onBeforeTransitionIn(event:GaiaEvent):void {
  // do something...
  releaseGaia();
}

另外在 Navigation 裡常用的手法,
// in init
Gaia.api.afterGoto(setPageId, false, false);

private function setPageId(e:GaiaEvent):void {
  trace(e.validBranch);
}
用來做 breadcrumb  還蠻方便的。

[ref]
http://www.gaiaflashframework.com/wiki/index.php?title=Events_and_Hijacking

2011年9月23日 星期五

facebook actionscript api (照片+相簿) - part3

方法一
facebook 上傳照片 + 開相簿:
自動開相簿 + post wall,不想 po 牆請設 no_story:'1',
var params:Object = {image:bitmap, message:'my message', fileName:'myfilename'};
Facebook.api("me/photos", onSaveToPhotoAlbumComplete, params);

2011年6月29日 星期三

[flash<->js] passing json using ExternalInterface

js call flash function(js -> flash)
[in flash]
ExternalInterface.addCallback("getData", fromJs_getData);

[in html]
var obj = document.getElementById("myflashcontent");
obj.getData();

flash call js function(flash ->js)
[in flash]
ExternalInterface.call("sendData", args);

[in html]
function sendData() {
console.log("sendData[0]:"+arguments[0]);
)

Google Maps API for Flash - 基本用法

Google Maps API for Flash
http://code.google.com/intl/zh-TW/apis/maps/documentation/flash/

先去這裡申請 API key
http://code.google.com/intl/zh-TW/apis/maps/signup.html

下載SDK
http://maps.googleapis.com/maps/flash/release/sdk.zip
flash use map_1_20.swc(swf檔案比用map_flex_1_20.swc小)

2011年6月8日 星期三

facebook actionscript api - part2

前一篇寫的落落長,避免以後忘記
包成 swc 方便使用,都已處理 facebook登入 及 取得權限 的部分。
facebook 相簿列表:FBAlbums.swc
facebook 好友列表:FBFriends.swc

範例:
import iqcat.ui.FBAlbumsList;
//import iqcat.ui.FBFriendsList;
//傳入參數:appid, 座標及長寬
var o:Object = { appid:APP_ID, x:10, y:50, w:620, h:330};
addChild(new FBAlbumsList(o));
//addChild(new FBFriendsList(o));