Php Facebook共享预览缓存og标记,即使查询参数发生更改
我使用php根据url参数生成动态og:image,但是,即使查询字符串不同,facebook仍然会缓存我设置的默认图像Php Facebook共享预览缓存og标记,即使查询参数发生更改,php,facebook-graph-api,Php,Facebook Graph Api,我使用php根据url参数生成动态og:image,但是,即使查询字符串不同,facebook仍然会缓存我设置的默认图像 <?php $selection = $_GET['selection']; $mixName = $_GET['mixName']; $title = "App title"; $description = "Default description&quo
<?php
$selection = $_GET['selection'];
$mixName = $_GET['mixName'];
$title = "App title";
$description = "Default description";
$image = "default image url";
if ($selection) {
$dynamicContent = file_get_contents('calling server to get custom image based on query parameters $selection);
$data = json_decode($dynamicContent, TRUE);
if ($data['image']) {
$image = $data['image'];
}
if ($mixName) {
$title = $mixName;
}
}
?>
<meta name="description" content="description">
<meta property="og:title" content="<?php echo $title ?>">
<meta property="og:url" content="website url">
<meta property="og:description" content="testabc">
<meta property="og:type" content="website" />
<meta property="og:image" content="<?php echo $image ?>">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?php echo $title ?>">
<meta name="twitter:image" content="<?php echo $image ?>">
<meta name="twitter:description" content="<?php echo $description ?>">
您还需要在og:url
中指定查询字符串参数
Facebook将其视为您正在共享的内容的“真实”URL,并将从那里请求OG元数据的其余部分
请注意,指定不同的URL也会在这些URL之间分割相似的内容并共享计数,即使您认为它们基本上是相同的内容。对于Facebook,不同的OG url意味着不同的开放图形对象。您是否也在OG:url
中指定了查询字符串参数?Facebook将其视为您正在共享的内容的“真实”URL,并将从那里请求OG元数据的其余部分。(请注意,指定不同的URL也会在这些URL之间分割您的相似项和共享计数,即使您认为它们基本上是同一内容。)该死,它没有尝试过,但解决方案就是这样。你想把它作为一个解决方案,我会接受答案吗?