我有一种情况,我打电话给 Facebook.showPermissionDialog('offline_access'...) 然后我打了一个 ajax.post 电话。如果之前调用了权限对话框,则 ajax.post 调用失败。但是当权限对话框没有被事先调用时,它会成功。有人知道这个对话框和 ajax.post 之间的某种关系吗?
如果您想直接检查问题,请访问我的应用程序http://apps.facebook.com/rails_dev(这是一个 FACEBOOK 应用程序,因此您必须授予对您个人资料的访问权限)。
下面是调用 Facebook.showPermissionDialog() 的代码:
<?php
echo $this->jsInit($config);
if(!$userNamespace->newGame) {
$log->debug('NOT new game, calling turnResume()');
echo 'setVarBalance(' . $this->gamePlayerData['funds'] . ');'."\n";
echo 'turnResume();'."\n";
}
echo $this->drawTrack($this->routeData, $this->trainData);
echo $this->drawCityGoods($this->cityGoodsData);
//$link = 'startSetCity()'; //$config->url->absolute->fb->canvas . '/turn/start-set-city';
echo $this->drawCitiesAjax($this->cityDescData);
$log->debug('view: end start-select-city');
if(!$facebook->api_client->users_hasAppPermission('offline_access', $this->fbUserId)):
?>
var dialog = new Dialog().showMessage('Constant Authorization', 'Rails Across Europe is about to request \'Constant Authorization\' to your account. If you don\'t give us constant authorization, Facebook will eventually cause your game to timeout, thereby losing all game information. By granting this authorization, Facebook will not cause your game to timeout. This is the only reason we need this authorization.');
dialog.onconfirm = function() {
Facebook.showPermissionDialog('offline_access', null, false, null);
}
<?php
endif;
?>[
这是调用 ajax.post 的 FBJS 代码:
switch(state) {
case START_SET_CITY:
//new Dialog().showMessage('test', 'START_SET_CITY');
//console.time('start_set_city');
ajax.responseType = Ajax.JSON;
ajax.ondone = function(data) {
//console.time('ondone');
//new Dialog().showMessage('in ajaxSetCity.ondone');
//new Dialog().showMessage('test', 'city=' + dump(data.city, 3) + '::: train=' + dump(data.train, 3));
drawCityAjax(data.city, data.train);
setVarBalance(data.funds);
ajax.responseType = Ajax.JSON;
ajax.post(baseURL + '/turn/start');
//console.timeEnd('ondone');
};
ajax.post(baseURL + '/turn/start-set-city', param); // <=== THIS IS THE AJAX CALL THAT FAILS
var actionPrompt = document.getElementById('action-prompt');
var innerHtml = '<span><div id="action-text">Build Track: Select a city where track building should begin</div>'+
'<div id="action-end">'+
'<input type="button" value="End Track Building" id="next-phase" onClick="moveTrainAuto();" />'+
'</div></span>';
actionPrompt.setInnerXHTML(innerHtml);
var btn = document.getElementById('next-phase');
btn.addEventListener('click', moveTrainAutoEvent);
state = TRACK_CITY_START;
//console.timeEnd('start_set_city');
// get funds balance from backend and call setVarBalance()
break;