當前位置:編程學習大全網 - 編程軟體 - 怎麽用PHP發送HTTP請求

怎麽用PHP發送HTTP請求

var?_loader:URLloader;

_loader?=?new?URLLoader();

//建立事件的偵聽

configureListeners(_loader);

//建立urlloader的數據

var?loaderData:URLVariables?=?new?URLVariables();

loaderData.userName?=?"kidliu";

loaderData.passWord?=?"123456";

//建立請求地址

var?url:String?=?"localhost/login.php";

var?request:URLRequest?=?new?URLRequest(url);

//把數據和請求邦定

request.data?=?loaderData;

//設定請求的方式

request.method?=?URLRequestMethod.POST;

try?{

_loader.load(request);

}?catch?(error:Error)?{

trace(error);

}

private?function?configureListeners(dispatcher:IEventDispatcher):void?{

//加載完成事件;

dispatcher.addEventListener(Event.COMPLETE,?loaderHandler);

//開始訪問事件;

dispatcher.addEventListener(Event.OPEN,?loaderHandler);

//加載進度事件;

dispatcher.addEventListener(ProgressEvent.PROGRESS,?loaderHandler);

//跨域訪問安全策略事件;

dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR,?loaderHandler);

//Http狀態事件;

dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS,?loaderHandler);

//訪問出錯事件;

dispatcher.addEventListener(IOErrorEvent.IO_ERROR,?loaderHandler);

}?

private?function?loaderHandler(event:*):void

{?

switch(event.type)?{

case?Event.COMPLETE:

trace("成功:?"?+?_loader.data);

break;

case?Event.OPEN:

trace("open:?"?+?event);

break;

case?ProgressEvent.PROGRESS:

trace("progress:?"?+?event);

break;

case?SecurityErrorEvent.SECURITY_ERROR:

trace("securityError:?"?+?event);

  • 上一篇:無人機駕駛員好就業麽?
  • 下一篇:北京朝陽某小學VR進課堂,是技術創新,還是作秀?
  • copyright 2024編程學習大全網