Reading php generated XML in flash?(在 Flash 中读取 php 生成的 XML?)
问题描述
这是我们问题的第 1 部分 (在 Flash 中将动态生成的 XML 文件加载为 PHP).
Here is part 1 of our problem (Loading a dynamically generated XML file as PHP in Flash).
现在我们能够让 Flash 读取 XML 文件,但是我们只能在实际 Flash 程序中测试(测试电影)时才能正确看到 Flash 渲染.但是,当我们在线上传文件进行预览时,Flash 无法正确呈现,缺少一些重要信息(缩略图、标题、视频等).
Now we were able to get Flash to read the XML file, but we can only see the Flash render correctly when tested(test movie) from the actual Flash program. However, when we upload our files online to preview the Flash does not render correctly, missing some vital information(thumbnails, titles, video etc..).
SWF 文件存在于域 1XML &PHP 文件都存在于域 2带有嵌入代码的 HTML 文件位于域 3
The SWF file exists on Domain 1 The XML & PHP file both exists on Domain 2 And the HTML file with the embed code lies on Domain 3
想知道这是否可能是跨域问题?我们在域 1 & 上有这些文件之一.2 我们也可以访问,但是对于域 3,我们不能在那里有 crossdomain.xml 文件.
Wondering if this could be a crossdomain issue? We have one of those files in place on Domain 1 & 2 where we have access too, however for Domain 3 we can't have a crossdomain.xml file there.
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->setIndentString(" ");
$xml->startDocument();
$xml->startElement('data');
$xml->startElement('config');
$xml->startElement('hex');
$xml->writeCData('0x' . $widget_profile['background_color']);
$xml->endElement();
$xml->startElement('width');
$xml->writeCData($widget_profile['width']);
$xml->endElement();
$xml->startElement('height');
$xml->writeCData($widget_profile['height']);
$xml->endElement();
$xml->startElement('fullscreen');
$xml->writeCData('false');
$xml->endElement();
$xml->startElement('special');
$xml->writeCData('false');
$xml->endElement();
$xml->startElement('specialName');
$xml->writeCData('Tools & Offers');
$xml->endElement();
$xml->startElement('specialLink');
$xml->writeCData('XXXXXX');
$xml->endElement();
$xml->startElement('client');
$xml->writeCData($widget_profile['site_url']);
$xml->endElement();
$xml->endElement();
if (count($widget_content) > 0) {
foreach ($widget_content as $tab) {
$xml->startElement('tab');
$xml->writeAttribute('id', $tab['tabname']);
if (count($tab['video']) > 0) {
foreach ($tab['video'] as $video) {
$video_sql = "select VID, flvdoname, title
from video
where VID='" . $video . "'";
$video_result = $howdini->query($video_sql);
if ($video_result->rowCount() > 0) {
foreach ($video_result as $video_row) {
$video_row['flvdoname'] = substr($video_row['flvdoname'], 35, -4);
$xml->startElement('vid');
$xml->writeAttribute('flv', $video_row['flvdoname']);
$xml->writeAttribute('thumb', 'XXXXXXXXX' . $video_row['VID'] . '.jpg');
$xml->writeAttribute('title', $video_row['title']);
$xml->endElement();
}
}
}
}
$xml->endElement();
}
}
$xml->endElement();
$xml->endDocument();
header('Content-Type: text/xml; charset=UTF-8');
echo $xml->flush();
预先感谢您的任何答案!我已经包含了更改,现在 Firebug 可以看到 XML.现在它只是看不到 swf 文件,但我可以在页面的其他部分看到 swf 文件.
Thanks in advance for any answers! I have included the change and now Firebug sees the XML. Now it's just not seeing the swf file but I can see the swf file in other parts of the page.
推荐答案
不是一个完整的解决方案,而只是一个数据点(因为编码问题很糟糕).当我通过静态文件和 PHP 文件下载你的 XML 并比较它们时,我得到了以下结果
Not a full solution, but just a data point (because encoding issues suck). When I downloaded your XML via the static file and PHP file and diffed them, I got the following results
% diff php.xml static.xml
1c1
< <?xml version="1.0"?>
---
> <?xml version="1.0"?>
10a11
>
19a21
>
您的静态文件的开头有一个额外的非 ASCII"字符.
Your static file has an extra "non-ASCII" character at the start of it.
我猜你的静态 XML 文件有一个 UTF-8 BOM,而 PHP 生成的文件没有,而且你的 Flash 电影需要一个 UTF-8 文件.我会尝试使用您的 PHP XML 文件生成 BOM 并查看它帮助或摆弄服务器的编码设置.
My guess is your static XML file has a UTF-8 BOM that PHP generated file doesn't, and that your flash movie is expecting a UTF-8 file. I'd try generating a BOM with your PHP XML file and seeing it it helps, or fiddling with your server's encoding settings.
尝试更改您的 PHP,使其输出以下标题(与嵌入电影的网页匹配).
Try changing you PHP so it outputs the following header (matching the web page the movie is embedded in).
header('Content-Type: text/html; charset=UTF-8')
这篇关于在 Flash 中读取 php 生成的 XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Flash 中读取 php 生成的 XML?
基础教程推荐
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01