【发布时间】:2017-02-03 15:40:09
【问题描述】:
我已经设置了一个比赛,要求参赛者在 facebook 上分享他们的结果。
我有以下按钮来分享结果:
print('<a class="facebook stemspeler" style="color:#eec920; margin-right:15px;" target="_blank" onclick="return !window.open(this.href, \'Facebook\', \'width=1200,height=300\')" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.***.com%2Fallstars&picture=http%3A%2F%2Fwww.***.com%2Ftypo.php?id='.$makeUniq.'&title=tet&caption=test&quote=test&description=test">Share</a>');
$makeUniq 确保 facebook 获取结果而不是第一次缓存结果(当链接保持不变时它会缓存,现在不会因为链接更改每个请求)。
typo.php 是包含图像的文件。它采用标准模板并将比赛输入转换为图像叠加层。
<?php
session_start();
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// Output to browser
header('Content-Type: image/png');
// Create a 300x150 image
//WHITE BACKGROUND COLOR
$im = imagecreatetruecolor(1000, 1000);
$im = imagecreatefrompng("images/test.png");
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$test = imagecolorallocate($im, 255, 255, 0);
// Set the background to be white
imagefilledrectangle($im, 0, 0, 900, 990, $test);
// Path to our font file
$font = 'fonts/DINPro-Medium.ttf';
$fontSize = 24;
$angle = 0;
$x = 80;
$y = 150;
// Write it
imagettftext($im, $fontSize, $angle, $x, $y, $white, $font, ' : n');
$x = 80;
$y = 200;
// Write it
imagettftext($im, $fontSize, $angle, $x, $y, $white, $font, 'k : ');
$x = 80;
$y = 250;
// Write it
imagettftext($im, $fontSize, $angle, $x, $y, $white, $font, 'Ler :n');
$x = 80;
$y = 300;
// Write it
imagettftext($im, $fontSize, $angle, $x, $y, $white, $font, 'Mouwer : ');
$x = 80;
$y = 350;
// Write it
imagettftext($im, $fontSize, $angle, $x, $y, $white, $font, 'Rwer n');
$x = 80;
$y = 400;
// Write it
imagettftext($im, $fontSize, $angle, $x, $y, $white, $font, 'Rechtk : ');
$x = 80;
$y = 450;
// Write it
imagettftext($im, $fontSize, $angle, $x, $y, $white, $font, 'Cir : ');
imagepng($im);
imagedestroy($im);
?>
到目前为止,一切都按预期进行。
问题是当 facebook 分享功能打开时,facebook 一直将图像显示为缩略图而不是大图像。
我尝试过多次更改分辨率,网上有几篇贴近描述这个问题的帖子。 有人知道我该如何解决这个问题吗?
提前致谢!
【问题讨论】:
标签: php facebook facebook-sharer