I'm using this code to merge text with an image and it's working fine. But when I use this code with Facebook app, it doesn't show any output. Can anyone please help me sorting out the problem? As far as I believe, the problem is with this line:
header("Content-Type: image/jpeg");
When I remove it, it shows some messed up output.
<?php
header("Content-Type: image/jpeg");
$im = ImageCreateFrompng("jump_empty.png");
$black = ImageColorAllocate($im, 255, 255, 255);
$start_x = 10;
$start_y = 20;
Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'ambient.ttf', "hellooo");
Imagejpeg($im, '', 100);
ImageDestroy($im);
?>
Here is the code I'm using for Facebook app:
<?php
include_once 'facebook.php';
include_once 'config.php';
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET_KEY,
'cookie' => true,
'domain' => '_____'
));
header("Content-Type: image/jpeg");
$session = $facebook->getSession();
if (!$session) {
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'req_perms' => 'read_stream,publish_stream'
));
echo "top.location.href = '$url';";
} else {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
echo "Hey " . $me['name'] . "!
";
$im = ImageCreateFrompng("jump_empty.png");
$black = ImageColorAllocate($im, 255, 255, 255);
$start_x = 10;
$start_y = 20;
Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'ambient.ttf', 'hello');
Imagejpeg($im, '', 100);
ImageDestroy($im);
}
catch (FacebookApiException $e) {
echo "Error:" . print_r($e, true);
}
}
?>
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)