I am trying to display some custom feeds on my website from a facebook fan page. This is a summary sample of the php used, and it works great.
[...html code...]
require_once('resources/facebook-php-sdk-master/src/facebook.php');
$config = array();
$config['appId'] = 'MY_APP_ID';
$config['secret'] = 'MY_SECRET_CODE';
$config['fileUpload'] = false;
$facebook = new Facebook($config);
$pageid = "MY_PAGE_ID";
$pagefeed = $facebook->api("/" . $pageid . "/feed");
[...html code...]
$i = 0;
foreach($pagefeed['data'] as $post) {
if ($post['type'] == 'photo') {
$picture_url = $post['picture'];
$picture_url_big = str_replace("s130x130/","", $picture_url);
echo "<p><img class=\"img-icon\" src=\"" . $post['icon'] . "\"></p>";
echo "<h2 class=\"data-post\">" . date("j-n-Y", (strtotime($post['created_time']))) . "</h2>";
echo "<div class=\"img-thumb\"><a href=\"" . $post['link'] . "\" target=\"_blank\"><img src=\"" . $picture_url_big . "\"></div></a>";
echo "<p class=\"manda-a-capo\"></p>";
if (empty($post['story']) === false) {
echo "<p>" . $post['story'] . "</p>";
} elseif (empty($post['message']) === false) {
echo "<p>" . $post['message'] . "</p>";
}
echo "<p><a href=\"" . $post['link'] . "\" target=\"_blank\"><u><b>Vedi foto</b></u></a></p>";
echo "<p class=\"manda-a-capo\"></p>";
if ($post['shares']['count'] != "") {
echo "<p class=\"manda-a-capo share-num\">" . $post['shares']['count'] . " condivisioni.</p>";
}
}
$i++;
}
[...other code...]
The facebook graph contains only the thumb index of photos, i.e. 130x130px. I found that some thumbs have the parameter “/ s130x130 /” in the URL and if you delete this parameter you get the photo in its actual size. So this explains this part of the code (as stated above):
$picture_url = $post['picture'];
$picture_url_big = str_replace("s130x130/","", $picture_url);
echo "<div class=\"img-thumb\"><a href=\"" . $post['link'] . "\" target=\"_blank\"><img src=\"" . $picture_url_big . "\"></div></a>";
, , , URL.
, , , .
URL-, ?
?
.
P.S.
php fb:
<?php
echo "<pre>";
print_r($pagefeed);
echo "</pre>";
?>