I’ve developed a Flash quiz app for facebook, which calls for a php script silently upon completion. The php script’s function is to generate an image from the POST data sent by the flash, and then post it to the user’s wall.
That would be all neat and dandy, but for some reason the image never gets uploaded, probably because when i call it, it’s like http://www.myhost.com/appfolder/img-generate.php, and the facebook SDK script inside gets an Oauth error, probably because it is not embedded in their canvas.
My question is:
If I’d like to have my php script generate an image and upload it to the fb wall, then how should I call it from the flash?
This is the AS2 code I’m using currently:
callRemoteFile = function(ourVariable:Number) {
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
if (result_lv.message=="success")
trace("done! "+result_lv.returnValue);
else
trace(result_lv.message);
} else {
trace("Error connecting to server");
return false;
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.ourVariable = ourVariable;
send_lv.sendAndLoad(" http://www.myhost.com/appfolder/img-generate.php", result_lv, "POST");
}
callRemoteFile(String(health.toString()));
and this is the img-generate PHP (I’ve omitted most of the image functions and the getting of the POST data, because they are unrelated to my problem here):
include 'facebook.php';
$app_id = "111111111111111";
$app_secret = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
));
$date = date("ymdHis");
$im = imagecreatefromjpeg('myimg.jpg');
imagejpeg($im,'temp/'. $date . md5($ida) . '.jpg');
$facebook->setFileUploadSupport(
"http://" . $_SERVER["SERVER_NAME"]
);
$photo = $facebook->api("/me/photos", "POST", array(
source => "@" . 'temp/'. $date . md5($ida) . '.jpg',
message => "Something to display with the image"
));
If I simply navigate to the php with my browser it giver me this:
Fatal error: Uncaught OAuthException: Invalid OAuth access token signature. thrown in /home/a01223445/public_html/appfolder/base_facebook.php on line 1039
If I view the same php through facebook canvas it works perfectly. My problem is: The canvas will show the flash and I want the php to silently be evaluated while the flash is running.
Sorry for the long question,
Thank you for your help in advance!
I had the same problem I needed to add the realpath()