我正在尝试将一些数据从我的 flex 应用程序发布到要保存的 PHP 脚本。
作为一个简单的测试,我已经制作了这样的 php 脚本
<?php
if ($_POST) {
$message = "Text:" . $_POST['Text'];
mail('vince@myemailaddress.com', 'POSTED!', $message);
} else {
mail('vince@myemailaddress.com', 'No Post Test', 'Testing..');
}
?>
如果我在浏览器中点击脚本,我会收到一封电子邮件。但是当我调用我的 flex 函数时,我什么也没得到?我做错了吗?
private function onTextMessageRecv(event:AsyncDataEvent):void
{
var dialogID:String = event.data;
var strFrom:String = event.data2;
var strTime:String = event.data3;
var MessageStr:String = event.data4;
var variables:URLVariables = new URLVariables()
variables.From = strFrom;
variables.To = m_strUserDisplayName;
variables.Text = MessageStr;
saveIMdata( variables);
}
private function saveIMdata( variables:URLVariables):void
{
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "Saving IM...");
var myData:URLRequest = new URLRequest("http://im.vlowe.co.uk/save.php")
myData.method = URLRequestMethod.POST
myData.data = variables
var loader:URLLoader = new URLLoader()
loader.dataFormat = URLLoaderDataFormat.VARIABLES
loader.load(myData)
}
我确实看到“正在保存 IM...”的日志条目,但没有电子邮件?
谢谢你的帮助。
更新: 试过这个..但两个事件似乎都没有触发?
private function saveIMdata( variables:URLVariables):void
{
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "Saving IM...");
var myData:URLRequest = new URLRequest("http://im.vlowe.co.uk/save.php");
myData.method = URLRequestMethod.POST;
myData.data = variables;
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, variables.Text);
var loader:URLLoader = new URLLoader();
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "Loaded?...");
loader.addEventListener(Event.COMPLETE, onLoadComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(myData);
}
private function onLoadComplete(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
trace(loader.data);
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "Load completed");
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, loader.data.toString());
}
private function onLoadError(e:IOErrorEvent):void
{
trace(e.text);
LogAddItem( LOG_CATEGORY_MAIN_DEBUG, "Error " + e.text);
}
更新 2: 我的 crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="80,843,8080,8081,8082" secure="false"/>
</cross-domain-policy>