将 xml 从 ActionScript 发送到 PHP

发布于 2024-09-03 12:34:35 字数 1114 浏览 1 评论 0原文

我在 Actionscript 的 XMLList 中有值。需要将这些值发送到数据库并更新它。 我的actionscript代码如下:

public static function saveUserPermList():void {

        var ht:HTTPService = new HTTPService();
        ht.url = Config.getServerURL();
        ht.method = URLRequestMethod.POST;
        //ht.resultFormat = "e4x";
        ht.contentType = "text/xml";
        ht.request["action"] = "saveUserPermListXML";
        ht.request["pdata"] = Application.application.userPermListModel.toString();
        ht.addEventListener(ResultEvent.RESULT,AdminUserList.saveUserPermListResult);
        ht.send();
    }
    public static function saveUserPermListResult(e:ResultEvent):void {
        trace(e);                   

    }
  1. 如何将XMLList数据发送到PHP?我应该添加一个 toString() 到它吗?
  2. Flex 中的 contentType 应该是什么?

我怎样才能在 PHP 中捕获这个,请告诉我,尝试使用这种方式,

if($user -> isAllowedAccess()) {

    header("Content-type:text/xml");
    $postedData =  $_POST["pdata"];     

   // $xmldoc = simplexml_load_string($POST['pdata']);
   // echo($xmldoc);

}

不走运。请告诉我。

I have values inside an XMLList in Actionscript. Need to send these values to the DB and update it.
My actionscript code is as follows:

public static function saveUserPermList():void {

        var ht:HTTPService = new HTTPService();
        ht.url = Config.getServerURL();
        ht.method = URLRequestMethod.POST;
        //ht.resultFormat = "e4x";
        ht.contentType = "text/xml";
        ht.request["action"] = "saveUserPermListXML";
        ht.request["pdata"] = Application.application.userPermListModel.toString();
        ht.addEventListener(ResultEvent.RESULT,AdminUserList.saveUserPermListResult);
        ht.send();
    }
    public static function saveUserPermListResult(e:ResultEvent):void {
        trace(e);                   

    }
  1. How can I send the XMLList data to PHP? Should I add a toString() to it?
  2. Also what should be the contentType in Flex.

How can I catch this inside PHP, pl let me know, trying to use, this way,

if($user -> isAllowedAccess()) {

    header("Content-type:text/xml");
    $postedData =  $_POST["pdata"];     

   // $xmldoc = simplexml_load_string($POST['pdata']);
   // echo($xmldoc);

}

No luck. Pl let me know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白衬杉格子梦 2024-09-10 12:34:35

HTTPServicemethod 属性可能应该是“POST”,请求本身的 contentType 可能应该是“application/x-www-形式 urlencoded”。

在 PHP 端,$_POST["pdata"] 将是一个包含 XML 标记的字符串。您可以直接将其保存在数据库中,或者首先将其解析为 XML(通过 SimpleXMLDOMDocument),然后对包含的数据执行某些操作。

PS:我刚刚发现 这个答案似乎揭示了HTTPService类的内部行为。

The method property of HTTPService should probably be "POST", and the contentType for the request itself should probably be "application/x-www-form-urlencoded".

On the PHP side, $_POST["pdata"] would then be a string containing XML markup. You could either save that in a database directly, or first parse it into XML (via SimpleXML or DOMDocument) and do something with the contained data.

PS: I've just found this answer that seems to shed some light on the internal behavior of the HTTPService class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文