dthp96899 2012-10-11 14:37
浏览 261

在Facebook上实时,动态生成图像共享

I'm trying to create simple facebook game. There is really required to do as much as possible on client-side. I generate dynamic .jpg to share game results on facebook wall using Feed method of FB.ui api. I've tried to use this code as image generator:

<?php
header ("Content-type: image/jpeg");

$pictureUrl = $_REQUEST['pic'];
$firstPlayerResult = $_REQUEST['fpr'];
$firstPlayerName = $_REQUEST['fpn'];
$secondPlayerResult = $_REQUEST['spr'];
$secondPlayerName = $_REQUEST['spn'];

$im = imagecreatefromjpeg($pictureUrl);


$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$verdanaBold = './verdanab.ttf';
$verdana = './verdana.ttf';

imagefttext($im, 16, 0, 12, 33, $white, $verdanaBold, $firstPlayerResult);
imagefttext($im, 12, 0, 12, 50, $white, $verdana, $firstPlayerName);

$dimensions = imagettfbbox(12, 0, $verdana, $secondPlayerName);
$textWidth = abs($dimensions[4] - $dimensions[0]);
$x = 693 - $textWidth;

imagefttext($im, 16, 0, 603, 33, $white, $verdanaBold, $secondPlayerResult);
imagefttext($im, 12, 0, $x, 50, $white, $verdana, $secondPlayerName);

imagejpeg($im);
?>

But there is a problem. Script works fine when is opening in a browser - its display correct .jpg screen, but when I'm trying to past the URL link (with GET request) to js script into 'picture' field of Feed method from FB.ui, its return internal error (500). Similiar behaviour appears when I'm trying directly past link on my facebook wall (facebook don't parse image and displays only URL). How can I fix it and display correctly image as facebook feed?

  • 写回答

1条回答 默认 最新

  • dqfkd82886 2017-03-28 02:47
    关注

    Yeah, because it's generated in the Front-end part and isn't saved as a proper image file. So the url isn't a permalink that it should be for you to be able to post something to FB

    评论

报告相同问题?

悬赏问题

  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私