Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   Flash + PHP + XML (http://www.flasher.ru/forum/showthread.php?t=84924)

awers 12.09.2006 07:03

Flash + PHP + XML
 
есть исходник fla:
Код:

on (click) {
        xml = new XML();
        loginElement = loginXML.createElement("LOGIN");
        loginElement.attributes.username = _root.login.text;
        loginElement.attributes.password = _root.password.text;
        xml.appendChild(loginElement);
        loginReplyXML = new XML();
        loginReplyXML.onLoad = function() {
                var e = this.firstChild;
                if (e.nodeName == "LOGINREPLY" && e.attributes.STATUS == "OK") {
                        trace("ok");
                } else {
                        trace("loginFailed");
                }
        };
        xml.sendAndLoad("http://localhost/login.xml.php", loginReplyXML);
}

В какую переменную или вообще куда я буду получать XML содержимое loginReplyXML ?

Смотрел в POST,GET.
HTTP_RAW_POST_DATA тож не хочет. Дык куда?

etc 12.09.2006 13:59

xml.contentType = 'text/xml';
и
$GLOBALS['HTTP_RAW_POST_DATA'];

В ответ нужно выслать
Код:

header("Content-Type: text/xml");
echo '<LOGINREPLY STATUS="OK"/>';


awers 13.09.2006 01:10

блин.... не отдает он как XML....
по крайней мере в RAW_POST я так и не получил данные формы...

awers 13.09.2006 03:59

вот новый код:
 
Код:

on (click) {
        xml = new XML();
        loginElement = loginXML.createElement("LOGIN");
        loginElement.attributes.username = _root.login.text;
        loginElement.attributes.password = _root.password.text;
        xml.appendChild(loginElement);
        loginReplyXML = new XML();
        loginReplyXML.onLoad = function() {
                var e = this.firstChild;
                if (e.nodeName == "LOGINREPLY" && e.attributes.STATUS == "OK") {
                        trace("ok");
                } else {
                        trace("loginFailed");
                }
                trace(loginReplyXML.toString());
        };
        xml.contentType = 'text/xml';
        xml.sendAndLoad("http://localhost/login.xml.php5", loginReplyXML,"POST");
}

тут пробовал и POST и GET и оставлял пустым ...
Код:

        xml.sendAndLoad("http://localhost/login.xml.php5", loginReplyXML,"POST");
вот код php:
Код:

<?php
echo $GLOBALS['HTTP_RAW_POST_DATA'];
?>

а в итоге все одно ...
Код HTML:

loginFailed
<br />
<b>Notice</b>:  Undefined index:  HTTP_RAW_POST_DATA in <b>z:\home\localhost\www\login.xml.php5</b> on line <b>2</b><br />


etc 13.09.2006 04:28

У меня ровным счётом тоже самое работает без проблем. Только в php4.
Не знаю, как там в php5.
И ещё, массив RAW POST доступен, только если указан contentType у XML.
И вообще, у тебя с XML полный бардак.
Код:

        xml = new XML();
        loginElement = xml.createElement("LOGIN");
        loginElement.attributes.username = _root.login.text;
        loginElement.attributes.password = _root.password.text;
        xml.appendChild(loginElement);

попробуй.

awers 13.09.2006 05:48

Я вообще ничего не понял, но как только переписал пример с НУЛЯ, все отлично заработало .... :rtfm:
Код:

on (click){
        xml = new XML();
        LE = xml.createElement("LoginInfo");
        LE.attributes.username = _root.login.text;
        LE.attributes.password = _root.pwd.text;
        xml.appendChild(LE);
        xml.contentType = "text/xml";
        _root.status.text = "Sending...: "+ xml.toString();
        xml1 = new XML();
        xml1.onLoad = function(){
                _root.status.text = _root.status.text + newline + "Answer..: "+xml1.toString();
                var e = this.firstChild;
                if (e.nodeName == "LOGINREPLY" && e.attributes.STATUS == "OK") {
                        _root.status.text = _root.status.text + newline + "Logged in";
                } else {
                        _root.status.text = _root.status.text + newline + "Can`t login";
                }

        }
        xml.sendAndLoad('http://localhost/login.xml.php',xml1);
       
}



Часовой пояс GMT +4, время: 06:29.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.