Aşşağıda gözüken kodlarla facebookta yorumlarda sitenin adını yazınca yanında rastgele resim çıkmasını sağlamam gerekiyor ancak olmuyor. Hep aynı resim çıkıyor başka insaların sitelerinde hep farklı resim çıkıyor.
index.php dosyası
<?php
include 'FacebookDebugger.php';
$fb = new FacebookDebugger();
$fb->reload('(xxx/)');
?>
<!DOCTYPE html>
<html>
<center>
<p><font face="fantasy" size="7" color="Black">
<b>Asagidaki Senin Takımın!</b></font></p>
<?php
$toplam = "27";
$resim_uzantisi = ".png";
$resim_klasoru = "images";
$ilk = "1";
$rastgele = mt_rand($ilk, $toplam);
$resim_adi = $rastgele . $resim_uzantisi;
echo "<img src="$resim_klasoru/$resim_adi" alt="$resim_adi" />";
?>
<head>
<title> Soldaki Senin Takımın. </title>
<meta charset="utf-8" />
</head>
<meta http-equiv="refresh" content="3;URL=xxx">
<property="og:title" content="<< Takımınız" />
<property="og:description" content="Begendiysen Sende Paylaş." />
<property="og:image" content="thumbnail_image" />
</center>
<script id="_wauq7h">var _wau = _wau || []; _wau.push(["classic", "j31t2z48c7ww", "q7h"]);
(function() {var s=document.createElement("script"); s.async=true;
s.src="//widgets.amung.us/classic.js";
document.getElementsByTagName("head")[0].appendChild(s);
})();</script>
<body>
</body>
</html>FacebookDebugger.php dosyası
<?php
class FacebookDebugger
{
/*
* https://developers.facebook.com/docs/opengraph/using-objects
*
* Updating Objects
*
* When an action is published, or a Like button pointing to the object clicked,
* Facebook will 'scrape' the HTML page of the object and read the meta tags.
* The object scrape also occurs when:
*
* - Every 7 days after the first scrape
*
* - The object URL is input in the Object Debugger
* http://developers.facebook.com/tools/debug
*
* - When an app triggers a scrape using an API endpoint
* This Graph API endpoint is simply a call to:
*
* POST /?id={object-instance-id or object-url}&scrape=true
*/
public function reload($url)
{
$graph = 'https://graph.facebook.com/';
$post = 'id='.urlencode($url).'&scrape=true';
return $this->send_post($graph, $post);
}
private function send_post($url, $post)
{
$r = curl_init();
curl_setopt($r, CURLOPT_URL, $url);
curl_setopt($r, CURLOPT_POST, 1);
curl_setopt($r, CURLOPT_POSTFIELDS, $post);
curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($r, CURLOPT_CONNECTTIMEOUT, 5);
$data = curl_exec($r);
curl_close($r);
return $data;
}
}
?>usage.php dosyası
<?php
include "FacebookDebugger.php";
$fb = new FacebookDebugger();
$fb->reload('xxx/');
$fb->reload('xxx/foo');
$fb->reload('xxx/bar');
?>