package src.template
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import
flash.net.URLLoaderDataFormat;
import
flash.net.URLRequest;
import
flash.net.URLRequestMethod;
import
flash.events.ProgressEvent;
import
flash.text.TextField;
public class SendToPhp
extends Sprite
{
private var
_result:TextField;
public function SendToPhp()
{
//建立一个文本框对象,登录成功后,在其中显示返回的Session
ID。
_result = new
TextField();
_result.autoSize
= "left";
_result.wordWrap
= true;
_result.width
= 300;
addChild(_result);
var
loginXML:XML =
<login>
<username>Kingda.org</username>
<password>ActionScript
3</password>
</login>;
var
request:URLRequest = new URLRequest("http://172.100.2.105/jfjs/index.php/astest/test");
request.contentType
= "text/xml";
request.data
= loginXML.toXMLString();
request.method
= URLRequestMethod.POST;
var
loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,
completeHandler);
try
{
trace ("loading...");
loader.load(request);
}
catch
(error:ArgumentError)
{
trace("参数错误");
}
catch
(error:SecurityError)
{
trace("发生安全错误");
_result.text = "发生安全错误。n" + error;
}
//trace(request.data);
}
private function
completeHandler(event:Event):void
{
trace(event.target.data); //服务器端返回的信息
">resultXML.@sessionid;*/
}
}
}
PHP CI代码:
<?php
class Astest extends Controller
{
public function __construct()
{
parent::Controller();
}
public function test()
{
$result=file_get_contents("php://input");
$xml=new SimpleXMLElements($result);
}
}