|
|
|
สอบถามการ สุ่ม facebook og image กับ title ทุกครั้งที่มีการรีเฟรช แบบเว็บนี้อย่างไรครับ |
|
|
|
|
|
|
|
ขอบคุณครับ ผมลองทดสอบดูแล้ว มันก็ไม่เคลียร์ cache ให้อยู่ดีครับ
Code (PHP)
<?php
$strCurrentURL = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$var = array(
"one" => array(
"title" => "Cat 1",
"image" => "http://i.imgur.com/mIcObyL.jpg"
),
"two" => array(
"title" => "Cat 2",
"image" => "http://i.imgur.com/agjj2s3.jpg"
),
"tree" => array(
"title" => "Cat 3",
"image" => "http://i.imgur.com/3cL9JSA.jpg"
),
);
$section = array_rand($var); //here yoy get random first of array(green or red or yellow)
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="twitter:card" value="summary">
<meta property="og:title" content="<?php echo $var[$section]['title']; ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php echo $url; ?>"/>
<meta property="og:image" content="<?php echo $var[$section]['image']; ?>" />
<meta property="og:description" content="Test"/>
<title>Test </title>
</head>
<body>
<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- Your share button code -->
<div class="fb-share-button"
data-href="<?php echo $strCurrentURL;?>"
data-layout="button_count">
</div>
</body>
</html>
|
|
|
|
|
Date :
2017-07-27 00:04:44 |
By :
10207386825108221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|