AMFPHP php远程调用(RPC, Remote Procedure Call)工具 快速入门教程

2019-04-09 21:07:18刘景俊

Alert.show("异常: " + result[1]);
}
}
public function faultHandler(event: FaultEvent):void
{//出错处理
Alert.show("sorry,出错了!!!");
}
}

二,PHP服务器端
1,将amfphp文件夹置于MyTest项目的根目录下,打开浏览器输入下述地址验证amfphp是否安装成功

http://localhost/MyTest/amfphp/gateway.php

amfphp就是通过这个gateway来定位我们的服务类,并将请求转发给这些服务类进行处理的。
2,Login.php文件,包含了处理登陆请求的Login类,此文件置于BusinessLogic目录下
代码

<?php
class Login
{
public function doLogin($data)
{
$result = array();
try {
$name = array_shift($data);
$pwd = array_shift($data);
if ($name == "phinecos" && $pwd == "123") {
$result[] = "1";
$result[] = "you are valid user!";
} else {
$result[] = "0";
$result[] = "login failed";
}
} catch (Exception $ex) {
$result[] = "-1";
$result[] = $ex->getMessage();
}
return $result;
}
}
?>

3,将globals.php中的服务路径项修改如下,为amfphp指明服务类所在的目录

$servicesPath = "../BusinessLogic/";

作者:洞庭散人
AMFPHP 下载地址
相关文章 大家在看