Current File : /home/aventura/www/web/modulos/modulos/app_galeria/index.php |
<?php
include "../../lib/template.inc";
require_once('resources/facebook-php-sdk-master/src/facebook.php');
$t = new Template('.');
//Archivos comunes
$t->set_file(array(
"ver" => "demo.html",
"una_imagen" => "una_imagen.html",
"un_comentario" =>"un_comentario.html",
"un_video" =>"un_video.html",
));
// connect to app
$config = array();
// '1453150144963196', 'ca789ce26c4d3ab8eabb10481d7b2450',
$config['appId'] = '1453150144963196';
$config['secret'] = 'ca789ce26c4d3ab8eabb10481d7b2450';
$config['fileUpload'] = false; // optional
// instantiate
$facebook = new Facebook($config);
// set page id
$pageid = "240693159294003";
// now we can access various parts of the graph, starting with the feed
$pagefeed = $facebook->api("/" . $pageid . "/feed");
$i = 0;
foreach($pagefeed['data'] as $post)
{
//Fotos
if ($post['type'] == 'photo')
{
if($post['status_type'] == "added_photos")
{
$t->set_var("info_imagen","Foto Subida: " . date("j M, Y", (strtotime($post['created_time']))) . "</h6>");
$t->set_var("imagen","https://graph.facebook.com/".$post['object_id']."/picture?type=normal");
$t->set_var("descripcion_imagen",$post['message']);
$t->parse("LISTADO_FACEBOOK","una_imagen",true);
}
}
if ($post['type'] == 'link')
{
if ($post['status_type']=="shared_story")
{
$imagen_cortada=explode('url=',$post['picture']);
$imagen=explode('&',$imagen_cortada[1]);
$imagen=urldecode($imagen[0]);
//$imagen = str_replace("&cfs=1", ":large", $imagen);
$t->set_var("imagen",$imagen.":large");
$t->set_var("info_imagen","Link Subido: " . date("j M, Y", (strtotime($post['created_time']))) . "</h6>");
$t->set_var("descripcion_imagen",$post['message']);
$t->parse("LISTADO_FACEBOOK","una_imagen",true);
}
}
if ($post['type'] == 'status')
{
$t->set_var("info_imagen","<h6 style='color:#74c5f2;'>Info Subida: " . date("j M, Y", (strtotime($post['created_time']))) . "</h6>");
$t->set_var("descripcion_imagen",$post['message']);
$t->parse("LISTADO_FACEBOOK","un_comentario",true);
}
//Videos
if ($post['type'] == 'video')
{
if ($post['caption'] == 'youtube.com')
{
$videos = str_replace("?autoplay=1", "", $post['source']);
$t->set_var("info_imagen","<h6 style='color:#74c5f2;'>Video Subida: " . date("jS M, Y", (strtotime($post['created_time']))) . "</h6>");
$t->set_var("video", "<div class='videoWrapper'><iframe width='560' height='349' src='".$videos."' frameborder='0' allowfullscreen></iframe></div>");
//$t->set_var("video", "<video poster='".$post['picture']."' controls><source src='".$post['source']."' type='video/mp4'></video> ");
$t->set_var("descripcion_imagen",$post['message']);
$t->parse("LISTADO_FACEBOOK","un_video",true);
}else{
$t->set_var("info_imagen","<h6 style='color:#74c5f2;'>Video Subida: " . date("jS M, Y", (strtotime($post['created_time']))) . "</h6>");
$t->set_var("video", "<video poster='".$post['picture']."' controls><source src='".$post['source']."' type='video/mp4'></video> ");
$t->set_var("descripcion_imagen",$post['message']);
$t->parse("LISTADO_FACEBOOK","un_video",true);
}
}
} // end the foreach statement
/*
echo "<pre>";
print_r($pagefeed);
echo "</pre>";
*/
$t->pparse("OUT", "ver");
?>