В AS 3.0 сделал по кнопке сохранение изменения в таблице БД на моём сервере. С локальной машины отрабатывает (создаёт лог-файл и апдейтит запись). Со страницы Вконтакте не отрабытывает (даже лог-файл не создаёт). Не подскажите в чём может быть проблема?
Вот код AS 3.0:
Код: Выделить всё
package { import flash.display.Loader; import flash.net.URLRequest; import flash.net.URLLoader; import flash.net.URLVariables; import flash.net.URLRequestMethod; import flash.events.Event; import flash.events.*; import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.*; import flash.utils.Timer; import flash.events.TimerEvent; import flash.events.*; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.system.Security; import flash.events.*; import vk.APIConnection; import flash.events.*; import flash.system.Security; import flash.text.TextField; import vk.*; import flash.display.Stage; /** * ... * @author Sokolov N.A. */ public class Main extends Sprite { public var payButton:PaySimpleButton; private var tf_p:TextField = new TextField(); private var cash:Number; private var flashVars:Object=stage.loaderInfo.parameters as Object; public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); postScore(); } private function init( e:Event = null ):void { payButton = new PaySimpleButton(); addChild(payButton); payButton.x = 336; payButton.y = 20; cash = 55; } //private function postScore():void { var loadpost:URLLoader = new URLLoader();var VK:APIConnection = new APIConnection(flashVars); //сюда пишем переменную ваших очковSecurity.allowDomain("*");Security.loadPolicyFile("http://мой домен/crossdomain.xml"); var loader:URLLoader = new URLLoader();var request:URLRequest = new URLRequest("http://мой домен/score.php");request.method = URLRequestMethod.POST;var variable:URLVariables = new URLVariables(); variable['uid'] = 'текущий uid';variable['score'] = cash; request.data = variable; loader.load(request);loader.addEventListener(Event.COMPLETE,function scorePosted(e:Event):void{ tf_p.htmlText = "COMPLETE"; tf_p.x = 410; tf_p.y = 26; tf_p.border = true; tf_p.alpha = 1.0; tf_p.autoSize = TextFieldAutoSize.CENTER; tf_p.borderColor = 0xFF0000; tf_p.width = 120;tf_p.height = 20; tf_p.selectable = false; addChild(tf_p); }); }// } }
Код: Выделить всё
<?phpheader("Content-Type: application/json; encoding=utf-8");$db_host="мой host";$db_user="мой user";$db_password="пароль user";$db_name = "имя db"; $score=$_POST['score'];$uid=$_POST['uid']; $api_id = 'api_id приложения';$secret_key = 'ключ secret_key'; $f = fopen('log000.txt', 'a');fwrite($f, date('d.m.y H:i:s', time()).' score= '.print_r($score). " uid= " . print_r($uid) . PHP_EOL);fclose($f); mysql_connect($db_host,$db_user,$db_password) or die (mysql_error()); mysql_selectdb($db_name); mysql_query('SET names "utf-8"'); $query = 'UPDATE `logs_add_mattery` SET `date` = "'.time().'", `score` = "'.$score.'" WHERE `uid` = "'.$uid.'";'; $sql = mysql_query($query);echo "OK"; ?>