“锻造” (= 模拟)AMFPHP 远程处理请求

发布于 2024-08-16 02:15:28 字数 292 浏览 4 评论 0原文

我使用 AMFPHP 非常成功地将我的数据库与我的 Flex 应用程序链接起来。但是,我希望能够通过键入以下内容来测试闪存之外的远程处理请求:

http:// /localhost/amfphp/gateway.php?[我在此处放置什么]

为了让浏览器(或 C++ http 组件)调用 amfphp 服务,在问号后面放置什么,以便 http 请求不需要从闪存“启动”。

I am using AMFPHP with great success to link my database with my Flex application. However I want to be able to test the remoting requests outside of flash, by typing something like:

http://localhost/amfphp/gateway.php?[WHAT DO I PUT HERE]

What do I put after the questionmark in order to have the browser (or a C++ http component) call the amfphp service, so that the http request needn't "initiate" from flash.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

神回复 2024-08-23 02:15:28

听起来您想从 PHP 进行 AMF 调用。您无法直接从浏览器执行此操作。数据将以二进制 AMF 格式返回,当然 PHP 或浏览器无法直接处理。我什至认为它不能提出要求。

您需要一个 AMF 客户端来进行调用并解码数据 - 我建议使用 SabreAMF。

Sabre AMF 主页

这是简单的客户端方法调用代码的样子。

require 'SabreAMF/Client.php';

function make_request($param1,$param2){
$client = new SabreAMF_Client('http://your.server/amfphp/gateway.php'); 
return $client->sendRequest('your_amf_service.yourAMFmethod',array($param1, $param2));
}

然后你像这样调用它

$result=make_request('cow',300);

,它会返回一个数组。

当然,您可能希望使用所有方法设置一个 PHP 类,以便可以轻松调用每个方法。

It sounds like you want to make an AMF call from PHP. You can't do this directly from a browser. The data would be returned in the binary AMF format, which of course PHP or a browser can't handle directly. I don't even think it can make the request.

You'll need a AMF client to make the call and decode the data - I suggest using SabreAMF.

Sabre AMF homepage

This is what simple client method call code looks like.

require 'SabreAMF/Client.php';

function make_request($param1,$param2){
$client = new SabreAMF_Client('http://your.server/amfphp/gateway.php'); 
return $client->sendRequest('your_amf_service.yourAMFmethod',array($param1, $param2));
}

you then invoke this like

$result=make_request('cow',300);

and it returns an array.

You'd probably want to set up a PHP class with all of your methods so you can call each one easily, of course.

執念 2024-08-23 02:15:28

AMFPHP 具有服务浏览器,它可以让您模拟对服务器端服务的调用并查看的回应。它基本上会向同一个服务文件发出内部 CURL 请求,并传入您提供的参数,并且就像直接从客户端 Flash 应用程序完成一样。

AMFPHP has the service browser, which lets you simulate calls to your server-side service and see the responses. It basically does an internal CURL request back to the same service file and passes in the arguments you provided, and acts as if it was done directly from the client-side Flash app.

季末如歌 2024-08-23 02:15:28

AMF 是一种二进制格式,事情可能不会那么简单:你会找出你的数据是如何编码的...

作为第一步,也许你可以从你的 gateway.php 脚本中,在从 flash 组件调用它时将它接收到的所有内容转储到文件中?

这样,您就可以看到接收到的数据的样子(并且您会知道它是通过 POST 还是通过 GET 传递)。

根据数据的样子,也许您能够“伪造”到您的服务器的请求 - 但我认为这不会像从浏览器调用 URL 那样简单......

AMF being a binary format, things are probably not going to be that simple : you'll have to find out how your data is encoded...

As a first step, maybe you could, from your gateway.php script, just dump everything it receives to a file, when it's called from your flash component ?

This way, you could see how the received data looks like (and you'd know if it's passed in POST, or in GET).

Depending on what that data looks like, maybe you'll be able to "forge" a request to your server -- but I don't think it'll be as simple as just calling an URL from your browser...

寄意 2024-08-23 02:15:28

考虑到 AMFPHP 网关只是一种转换(从/到二进制)并分派到具有各种传入参数以及最终数据 return() 的类/方法的机制 - 您是否可以直接针对该方法进行单元测试,从而跳过整个 AMF 层?

Considering the AMFPHP gateway is just a mechanism to translate (from/to binary) and dispatch to a class/method with various incoming parameters and finally a return() of data - can you just unit-test directly against the method, thus skipping the entire AMF layer?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文