0

我正在尝试使用 AMF PHP 将变量传递给 flash 文件,到目前为止我看不到我的代码有任何问题,但我对创建类的经验很少,所以就这样吧,这是我的代码,

索引.php:

<?php
include "amfphp/services/flashMe.php";

$session = true;

if ($session == true) {
 $uid = '12345';


  $thing = new flashMe;
  $thing->push($uid);

} else {

 //login

}

?>

flashMe.php:

<?php
class flashMe {

 public function __construct() {

 }

 public function push($one)
 {   
    return $one;//sends the uid to the flash file?
 }

}
?>

Flash 正在寻找 flashMe 类和该类中的 push 方法,但是当我运行它时,我的 flash 文件中不断出现空变量,这段代码有什么问题吗?

提前谢谢!

4

3 回答 3

2

您的 index.php 文件是不必要的。

您的第二个文件不完整。这是他们的“hello world”类文件的文档示例:

<?php
class HelloWorld
{
    function HelloWorld()
    {
        $this->methodTable = array
        (
            "say" => array
            (
                "access" => "remote",
                "description" => "Pings back a message"
            )
        );
    }

    function say($sMessage)
    {
        return 'You said: ' . $sMessage;
    }
}
?>

此文件应保存为与您在 php 文件中命名的“class HelloWorld”匹配的“HelloWorld”(您使用 FlashMe 正确完成了这部分)。

Flash 片(在 actionscript 中)的文档中的示例文件在这里:

import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;

var gatewayUrl:String = "http://localhost/flashservices/gateway.php"

NetDebug.initialize();
var _service:Service = new Service(gatewayUrl, null, 'HelloWorld', null , null);
var pc:PendingCall = _service.say("Hello world!");
pc.responder = new RelayResponder(this, "handleResult", "handleError");

function handleResult(re:ResultEvent)
{
    trace('The result is: ' + re.result);
}

function handleError(fe:FaultEvent)
{
    trace('There has been an error');
}

网关 URL 应该指向可以访问您的服务的任何地方。我敢肯定,如果你尝试几个,你会找到合适的。amfphp 的巧妙之处在于,它还允许您在尝试在网关中实现它们之前测试您的服务(如果您在浏览器中访问 URL)。

我对 AMFPHP 也很陌生,但我发现这些文档非常有用。如果您需要有关课程的更多帮助,可以在PHP 文档页面上找到更多信息。

于 2010-07-19T19:39:17.583 回答
0

之后你错过了括号new flashMe

$thing = new flashMe(); $thing->push($uid);

于 2010-07-09T14:09:24.673 回答
0

Amfphp 或 Zend AMF 仅允许您在网关公开的远程类上调用公共方法。您的示例不是一个类,因此不能调用任何远程方法。这看起来更像是使用 http 帖子所做的事情。

http://framework.zend.com/manual/en/zend.amf.server.html

于 2010-07-12T02:06:19.540 回答