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}
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.