我只是试图让我的用户使用 stageWebView 从 FB 获取访问令牌。当我跟踪位置更改/更改事件的输出时,我得到的只是 google/FB url,它们都没有令牌。
这是我的代码:
var webView:StageWebView = new StageWebView();
function onChanging(e:LocationChangeEvent):void {
trace(e.location);
e.preventDefault();
webView.loadURL(e.location);
webView.stage = null;
}
function onChange(e:LocationChangeEvent):void {
trace(webView.location);
if(webView.location.indexOf("http://google.com") == 0 && webView.location.indexOf("access_token")!=-1) {
trace("?"+webView.location.substring(webView.location.indexOf("access_token"), webView.location.indexOf("&expires_in")));
webView.stage = null;
}
}
function connectFb() {
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGING, onChanging);
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, onChange);
webView.stage = stage;
webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
webView.loadURL("https://graph.facebook.com/oauth/authorize?client_id=123456789012345&redirect_uri=http://google.com&type=user_agent&display=popup")
}
我的代码输出:
https://graph.facebook.com/oauth/authorize?client_id=164534120383085&redirect_uri=http://google.com&type=user_agent&display=popup
https://www.facebook.com/dialog/oauth?client_id=164534120383085&redirect_uri=http%3A%2F%2Fgoogle.com&type=user_agent&display=popup
https://www.facebook.com/dialog/oauth?client_id=164534120383085&redirect_uri=http%3A%2F%2Fgoogle.com&type=user_agent&display=popup
http://google.com/
http://google.com/
http://www.google.com/
http://www.google.com/
我尝试了网上的所有教程,甚至还买了一本关于 AS3 facebook dev 的书,但仍然无法弄清楚;任何帮助将不胜感激,因为这对我来说是一个相当重要的项目