Код во AS3:
Код: Выделить всё
import flash.events.MouseEvent;import flash.net.URLLoader;import flash.net.URLRequest;import flash.net.URLVariables;import flash.events.Event;import flash.system.Security; var flashVars:Object; if (stage) onAddedToStage();else addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);function onAddedToStage(event:Event = null) { flashVars = stage.loaderInfo.parameters as Object; tf.text = 'Please, click on the button below'; vk_tf.appendText('Your VK id: ' + String(flashVars.viewer_id) + ' '); vk_tf.appendText('Your auth_key: '+ String(flashVars.auth_key)); Security.allowDomain("my_domain");} b.addEventListener(MouseEvent.CLICK, f);function f (event:MouseEvent) { var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("http://my_php_file.php"); request.method = URLRequestMethod.POST; request.url = "http://my_php_file.php"; var vars:URLVariables = new URLVariables(); vars['viewer_id'] = flashVars.viewer_id; //Current user vars['auth_key'] = flashVars.auth_key; //Auth key //vars['viewer_id'] = '12345'; //vars['auth_key'] = 'qwert12345asdfg67890'; loader.addEventListener(Event.COMPLETE, onComplete); request.data = vars; loader.load(request); function onComplete(event:Event) { trace(loader.data); }
мой код на php:
Код: Выделить всё
<?php require('VkApi.class.php'); $app_id = '987654321';$api_secret = 'abcdefg12345abcdefg12345'; $UserID = $_POST['viewer_id'];$auth_key = $_POST['auth_key']; $real_key = md5($app_id."_".$UserID."_".$api_secret);if ($real_key == $auth_key) { function get_url($query) {$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $query);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_TIMEOUT, 10);return curl_exec($ch);curl_close($ch);}$api = new VkApiNode($app_id, $api_secret);get_url($query = $api->withdrawVotes($UserID, 100));echo 'Transfer completed succesfully!';} ?>
Написал потом что-то вроде:
Код: Выделить всё
import flash.events.Event;import flash.net.*; var loader:URLLoader = new URLLoader();var request:URLRequest = new URLRequest("http://my_php_file.php");request.method = URLRequestMethod.POST;request.url = "http://my_php_file.php";var vars:URLVariables = new URLVariables();vars.votes = '100';request.data = vars;loader.dataFormat = URLLoaderDataFormat.BINARY;loader.addEventListener(Event.COMPLETE, onComplete);loader.load(request);function onComplete(event:Event) { //do something trace(loader.data);}
Код: Выделить всё
<?php$votes = $_POST['votes'];echo $votes;?>
объясните мне, пожалуйста, в чем у меня проблемы? с php я знаком пару дней. но с Flash уже давно, но что-то не могу понять, в чём дело? заранее спасибо