dongtun1209 2010-07-09 04:37
浏览 54
已采纳

实例化AMF PHP类无法正常工作

I am trying to use AMF PHP to pass variables to a flash file, thus far I cannot see anything wrong with my code, but I have very little experience with creating classes, so here it goes, here is my code,

index.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 is looking for the flashMe class and the push method within that class, but I keep getting null variables in my flash file when I run it, is there something wrong with this code?

Thanx in advance!

展开全部

  • 写回答

3条回答 默认 最新

  • doutuosai3504 2010-07-19 11:39
    关注

    Your index.php file is unnecessary.

    Your second file is incomplete. Here is the example from the docs for their "hello world" class file:

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

    This file should be saved as "HelloWorld" matching the "class HelloWorld" you have named in the php file (you did this part right with FlashMe).

    The example file in the docs for the Flash piece (in actionscript) is here:

    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');
    }
    

    The gateway URL should go to wherever your services can be reached. I'm sure if you try a few you'll find the right one. The neat thing about amfphp is that it allows you to also test your services out before you try implementing them in the gateway (if you go to the URL in your browser).

    I'm pretty new to AMFPHP as well, but I've found the docs to be extraordinarily useful. If you need more help on classes, you can find more info on the PHP docs page.

    展开全部

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部