![]() |
|
||||||||||
|
|||||
|
Регистрация: Jun 2008
Сообщений: 34
|
Цитата:
вобщем дело в сервере (PHP) при посылке XML на сервер, сам сервер его получает в RAW сыром веди как я понял, вытаскиваются все данные в виде $GLOBALS["HTTP_RAW_POST_DATA"] а не в $_POST как я думал... вот пример нашёл: AS3 // Generate a random score to save with the username
var score:int = Math.floor( Math.random( ) * 10 );
// Create a new XML instance containing the data to be saved
var dataToSave:XML = <gamescore>
<username>{_username.text}</username>
<score>{score}</score>
</gamescore>;
// Point the request to the script that will handle the XML
var request:URLRequest = new URLRequest( "http://www.sd-ii.fr/gamescores.php" );
// Set the data property to the dataToSave XML instance to send the XML
// data to the server
request.data = dataToSave;
//request.data = variables;
// Set the contentType to signal XML data being sent
request.contentType = "text/xml";
// Use the post method to send the data
request.method = URLRequestMethod.POST;
// Create a URLLoader to handle sending and loading of the XML data
var loader:URLLoader = new URLLoader( );
// When the server response is finished downloading, invoke handleResponse
loader.addEventListener( Event.COMPLETE, handleResponse );
// Finally, send off the XML data to the URL
loader.load( request );
PHP // Read In XML from Raw Post Data.
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
// Process XML using DOM PHP extension.
$document = xmldoc($xml);
// Read root element <gameinfo>.
$rootElement = $document->root( );
// Read child nodes <username> and <score>.
$childNodes = $rootElement->children( );
$data = "";
// Loop through child nodes and place in array.
foreach($childNodes as $childNode){
// Add data to array;
$name = $childNode->tagName( );
$value = $childNode->get_content( );
$data[$name] = $value;
}
// Append data to scores.txt ( format: username|score )
$fp = fopen("scores.txt","a+");
$dataString = $data['username'] . "|" . $data['score'] . "\n";
fwrite($fp,$dataString,strlen($dataString));
fclose($fp);
// Return success code to Flash
echo "<success>1</success>";
также можно к ссылке запроса добавлять время что бы обойти хеширование (тут я ещё не до конца допёр как имео хеширование происходит) можно даже тему перекинуть на серверные технологии
__________________
miada.ru |
![]() |
Часовой пояс GMT +4, время: 16:50. |
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | |
| Опции просмотра | |
|
|