Flash调用一个PHP函数 [英] Flash calling a PHP function
问题描述
是否可以从Flash调用PHP函数并立即执行?
如果是这样,我怎么能这样做,因为我试图调用一个PHP函数,将更新用户Facebook的状态,但迄今为止,我一直不成功,所以我是在我的绳索结束。
任何帮助将我们的想法将类似于以下内容:
$ b
$ b
function updateFBStatus(newStatus)
{
//创建两个LoadVars实例,一个发送,一个接收数据
var dataOut:LoadVars = new LoadVars();
var dataIn:LoadVars = new LoadVars();
//定义收到响应时会发生什么,
//使用'this'来引用dataIn并从中获取数据
dataIn.onLoad = onReturn;
dataOut [newStatus] = newStatus;
dataOut.sendAndLoad(serverURL +setFBStatus.php,dataIn,POST);然后定义 setFBStatus.php
code>在你的服务器上的文件读取 $ _ POST ['newStatus']
并做任何你通常会在PHP中设置Facebook的状态。如果需要的话,那么php文件可以选择地以url请求格式(即, paramName1 = param1& paramName2 = param2&
)返回一些返回值,以供你的onReturn函数读取。
is it possible to call a PHP function from flash and have it execute right away?
If so how could I go about doing that, because I am trying to call a PHP function that will update a users facebook status, but thus far I have been unsuccessful, so I am kind of at the end f my rope.
Any help would be appreciated, thanx!
解决方案 My idea would be something similar to the following:
function updateFBStatus(newStatus)
{
// create two new instances of LoadVars, one to send and one to receive data
var dataOut:LoadVars = new LoadVars();
var dataIn:LoadVars = new LoadVars();
// define what should happen when the response is received,
// using 'this' to refer to dataIn and get data from it
dataIn.onLoad = onReturn;
dataOut["newStatus"] = newStatus;
dataOut.sendAndLoad(serverURL+"setFBStatus.php", dataIn, "POST");
}
You then define the setFBStatus.php
file on your server to read $_POST['newStatus']
and do whatever you would normally do in php to set the facebook status. That php file can optionally echo some return values in url request format (i.e, paramName1=param1¶mName2=param2&
) for your onReturn function to read, if you need to.
这篇关于Flash调用一个PHP函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!