IE8 最大 FlashVar 长度?
使用 swfobject 和 IE8 时,flashvars 字符串是否有某种最大长度?
我通过 FlashVars 将 Facebook 会话对象传递到 Flash,在 FF 和 Chrome 中效果很好。然而在IE中,似乎只传递了一定量的数据,并且字符串在任意点处被切断。这会导致 Flash 错误地解析传入数据。
获取会话对象的 PHP:
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
if(isset($_REQUEST['signed_request'])) {
$session = json_encode(parse_signed_request($_REQUEST['signed_request'],'<<APP SECRET>>'));
} else {
$session = '';
}
$lang = 'UK';
组装 FlashVars:
var flashvars = {
popUpsAllowed:true,
deployPath:"<<PATH>>",
fb_type:"popup",
fb_environment:"iframe",
fb_app_id:"<<APP ID>>",
fb_redirect:"<<REDIRECT URL>>",
session:'<?php echo $session; ?>',
lang:'<?php echo $lang; ?>',
nobreak:null }
现在在 IE 中运行的 Flash 中尝试访问 stage.loaderInfo.parameters.session 会抛出空对象错误,但在 FF 中工作正常。
我是否必须通过 externalInterface 请求会话以避免 FlashVar 过载?
编辑:因此,将会话变量拿走并稍后通过ExternalInterface请求它是可行的,但我想知道是IE还是ActiveX插件出了问题。
会话数据如下所示(一些数字字符已更改):
{"algorithm":"HMAC-SHA256","expires":1304334000,"issued_at":1304327676,"oauth_token":"100076334000000|0.kNHAz0AST_cq0jo7WLWldQ__.0000.0004334000.1-000000000|UIy7h_0NFYByedFUGDkxOntP8Sg","user":{"country":"gb","locale":"en_GB","age":{"min":21}},"user_id":"000000000"}
Edit2:* 所以我是个白痴,当您在 IE 开发工具中查看代码时,它确实会裁剪掉负载,但会复制元素的内部将 html 放入文本编辑器中可以让您看到整个内容。因此,会话字符串似乎没有损坏,但它仍然无法正确进入闪存,loaderInfo.parameters.session
存在但为空,loaderInfo.parameters.lang
> 未定义。
这是 FlashVars 的实际浏览器输出:
var flashvars = {
popUpsAllowed:true,
deployPath:"http://www.mydomain.com",
fb_type:"popup",
fb_environment:"iframe",
fb_app_id:"00000000000000000000000000000000",
fb_redirect:"http://apps.facebook.com/myApp/iframe_popup.php",
session:'{"algorithm":"HMAC-SHA256","expires":1304416800,"issued_at":1304412506,"oauth_token":"000176004606000|2.01KBxkU8muE0AeIQSNlXLg__.3000.1304400800.0-500428000|_KXAwxTxzGSmasOu0KlNFHQ0d7A","user":{"country":"gb","locale":"en_GB","age":{"min":21}},"user_id":"000000000"}',
lang:'UK',
nobreak:null}
Is there some kind of maximum length for a flashvars string when using swfobject and IE8?
I'm passing a Facebook session object into Flash via FlashVars, and in FF and Chrome this works fine. In IE howver, it seems that only a certain amount of data is passed, and the string is cut off at an arbitrary point. This results in Flash incorrectly parsing the incoming data.
The PHP that gets the session object:
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
if(isset($_REQUEST['signed_request'])) {
$session = json_encode(parse_signed_request($_REQUEST['signed_request'],'<<APP SECRET>>'));
} else {
$session = '';
}
$lang = 'UK';
Assembling the FlashVars:
var flashvars = {
popUpsAllowed:true,
deployPath:"<<PATH>>",
fb_type:"popup",
fb_environment:"iframe",
fb_app_id:"<<APP ID>>",
fb_redirect:"<<REDIRECT URL>>",
session:'<?php echo $session; ?>',
lang:'<?php echo $lang; ?>',
nobreak:null }
So now in Flash running in IE attempting to access stage.loaderInfo.parameters.session
throws a null object error, but works fine in FF.
Am I going to have to resort to requesting the session through externalInterface to avoid overloading the FlashVars?
EDIT: So taking the session var away and requesting it later through ExternalInterface works, but I'd like to know whether it's IE or the ActiveX plugin that's at fault here.
The session data looks like this (some numeric characters changed):
{"algorithm":"HMAC-SHA256","expires":1304334000,"issued_at":1304327676,"oauth_token":"100076334000000|0.kNHAz0AST_cq0jo7WLWldQ__.0000.0004334000.1-000000000|UIy7h_0NFYByedFUGDkxOntP8Sg","user":{"country":"gb","locale":"en_GB","age":{"min":21}},"user_id":"000000000"}
Edit2:* So I'm an idiot, when you view code in the IE Dev Tool it does crop off loads, but copying an element's inner html into a text editor lets you see the whole thing. So the session string doesn't seem to be corrupted, but it's still not getting into flash correctly, loaderInfo.parameters.session
exists but is null, and loaderInfo.parameters.lang
is not defined.
This is the actual browser output of the FlashVars:
var flashvars = {
popUpsAllowed:true,
deployPath:"http://www.mydomain.com",
fb_type:"popup",
fb_environment:"iframe",
fb_app_id:"00000000000000000000000000000000",
fb_redirect:"http://apps.facebook.com/myApp/iframe_popup.php",
session:'{"algorithm":"HMAC-SHA256","expires":1304416800,"issued_at":1304412506,"oauth_token":"000176004606000|2.01KBxkU8muE0AeIQSNlXLg__.3000.1304400800.0-500428000|_KXAwxTxzGSmasOu0KlNFHQ0d7A","user":{"country":"gb","locale":"en_GB","age":{"min":21}},"user_id":"000000000"}',
lang:'UK',
nobreak:null}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要对其进行 urlencode。我认为管道和冒号就是你的问题所在。 Flashvars 传递到查询字符串上的 swf。 IE 开发工具栏崩溃了,因为它无法渲染管道或冒号。
You need to urlencode it. Pipes and colons I think are what your problem is. Flashvars get past to the swf on the query string. The IE dev tool bar was breaking because it couldn't render the pipe or colon.
所有浏览器都支持长度最大为 64KB(65535 字节)的字符串。 FlashVars 必须在 OBJECT 和 EMBED 标记中分配才能在所有浏览器上工作。查看 Adobe 对 FlashVars 的看法,网址为使用 FlashVars 将变量传递给 SWF。
All browsers will support string sizes of up to 64KB (65535 bytes) in length. FlashVars must be assigned in both the OBJECT and EMBED tags in order to work on all browsers. Check out Adobe's take on FlashVars at Using FlashVars to pass variables to a SWF.