<?php require_once 'app/init.php'; ?>
<?php echo View::make('header')->render() ?>
<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&appId=1499626773621182&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php if (Auth::check()): ?>
<div id="body">
<?php
// Walid
$facebook_user_id = false;
$facebookConfig = array(
'appId' => Config::get("services.facebook.id"),
'secret' => Config::get("services.facebook.secret"),
'fileUpload' => false, // optional
'allowSignedRequest' => false, // optional, but should be set to false for non-canvas apps
);
$_id = @Auth::user()->usermeta['facebook_id'];
$_access_token = @Auth::user()->usermeta['facebook_access_token'];
if($_id && $_access_token ) {
require 'facebook/facebook.php';
$facebook = new Facebook($facebookConfig);
$facebook->setAccessToken($_access_token);
$facebook_user_id = $facebook->getUser();
}
// if( $facebook_user_id ) {
// try {
// $request = $facebook->api('/me/activities?access_token='.$_access_token);
// $request = $facebook->api('/me/feed?access_token='.$_access_token);
// $request = $facebook->api('/me/friends?access_token='.$_access_token);
// $request = $facebook->api('/me/permissions?access_token='.$_access_token);
//
// print_r($request);
//
// } catch(FacebookApiException $e) {
// $result = $e->getResult();
// echo "Errrrrrror ";
// echo json_encode($result);
// }
//
// $request = false;
// try {
// $request = $facebook->api('/me/activities?access_token='.$_access_token);
// $request = $facebook->api('/me/feed?access_token='.$_access_token);
// $request = $facebook->api('/me/friends?access_token='.$_access_token);
// $request = $facebook->api('/me/permissions?access_token='.$_access_token);
// $request = $facebook->api('/me/music?access_token='.$_access_token);
//
//
//
// $fql = "select post_id,actor_id,created_time,message,description,xid from stream where source_id = me()";
// $request = $facebook->api('/fql?access_token='.$_access_token.'&q={'.$fql.'}');
//
// } catch(FacebookApiException $e) {
// $result = $e->getResult();
// echo "Errrrrrror ";
// echo json_encode($result);
// }
//
// var_dump($request);
// if($request) {
// foreach($request as $k=>$v) {
// var_dump($v);
// }
// }
// }
//
//echo " Face Book";
//exit;
?>
<div class="jumbotron" style=" background: none;">
<div class="row">
<div class="col-xs-12 col-md-2">
<h2>Menu</h2>
</div>
<div class="col-xs-12 col-md-10">
<h3>Feed</h3>
<?php
$data = array();
if( $facebook_user_id ) {
try {
// $request = $facebook->api('/me/feed?access_token='.$_access_token);
$request = $facebook->api('/me/home?access_token='.$_access_token);
if($request && $request['data']) {
// var_dump($request);
$data = $request['data'];
}
} catch(FacebookApiException $e) {
$error = $e->getResult();
// var_dump($error);
}
}
if($data) {
//var_dump($data);
// id, from (id, name, category), message, embed_html,
// icon [link], source ['link], picture [link],
// LINK: link [link]
// name, caption, description,
// format (embed_html, width, height, filter, picture [link], ),
// updated_time, created_time,
// tags, comments,
foreach($data as $row) {
// print_r($row);
if(strpos(@$row['id'], '_')) {
$explode = explode('_', @$row['id']);
$link = "https://www.facebook.com/{$explode[0]}/posts/{$explode[1]}/";
} else {
$from_id = @$row['from']['id'];
$link = "https://www.facebook.com/{$from_id}/posts/{$id}/";
}
$type = @$row['type'];
switch($type) {
case 'link':
if(isset($row['story'])) {
$type = 'story';
}
break;
case 'status':
if(isset($row['story'])) {
$type = 'story';
}
break;
}
switch($type) {
case '--------------------------------':
// case 'link':
// case 'status':
break;
default:
// echo "<pre style='text-align:left;'>"; print_r($row); echo "</pre>";
break;
}
$icon = (isset($row['icon'])) ? '<img src="'.$row['icon'].'" class="pull-right" />' : '';
?>
<div class="row feeds feed-<?php echo $type; ?>" style="display: none;">
<div class="col-xs-12 head">
<?php echo $icon; ?>
<div class="pull-left mr10 thumb thumb50">
<img src="https://graph.facebook.com/<?php echo @$row['from']['id']; ?>/picture/" />
</div>
<span class="name"><?php echo @$row['from']['name']; ?></span>
</div>
<div class="col-xs-12">
<?php if($type=='link') { ?>
<div class="messageBox"><?php echo nl2br(@$row['message']); ?></div>
<div class="linkBox">
<div class="pull-left picture">
<img src="<?php echo @$row['picture']; ?>" width="100" />
</div>
<div class="details">
<div class="title"><a href="<?php echo @$row['link']; ?>#" target="_blank"><?php echo @$row['name']; ?></a></div>
<div class="description"><?php echo nl2br(@$row['description']); ?></div>
<div class="caption"><?php echo @$row['caption']; ?></div>
</div>
<div class="row"></div>
</div>
<?php } else if( $type=='story') { ?>
<div class="messageBox">
<div class="pull-left ml10 mr10 thumb thumb25">
<img src="<?php echo @$row['picture']; ?>" />
</div>
<span><a href="<?php echo @$row['link']; ?>#" target="_blank"><?php echo @$row['story']; ?></a></span>
</div>
<?php } else if( $type=='status') { ?>
<div class="messageBox"><?php echo nl2br(@$row['message']); ?></div>
<?php } else { ?>
<div class="messageBox"><?php echo nl2br(@$row['message']); ?></div>
<?php } ?>
</div>
<?php if( isset($row['actions']) && is_array($row['actions'])) {?>
<div class="col-xs-12 actionsBox">
<?php
$dash = '';
foreach($row['actions'] as $act) {
echo "{$dash}<a href=\"{$act['link']}\" target=\"blank\">{$act['name']}</a>";
$dash = ' - ';
}
?>
</div>
<?php } ?>
</div>
<div class="entry clearfix">
<div class="profile"><a href="http://www.facebook.com/profile.php?id=<?php echo @$row['from']['id']; ?>"><img src="http://graph.facebook.com/<?php echo @$row['from']['id']; ?>/picture"/></a></div>
<div class="body">
<div class="message">
<a class="name" href="http://www.facebook.com/profile.php?id=<?php echo @$row['from']['id']; ?>"><?php echo htmlspecialchars($row['from']['name'], ENT_QUOTES); ?></a>
<?php echo (isset($row['message'])) ? htmlspecialchars($row['message'], ENT_QUOTES) : ''; ?>
</div>
<?php if(!empty($row['caption']) || !empty($row['picture'])){ ?>
<div class="attachment clearfix<?php if(empty($row['picture'])){ ?> nopicture<?php } ?>">
<?php if(!empty($row['picture'])){ ?>
<div class="picture"><a href="<?php echo htmlspecialchars($row['link'], ENT_QUOTES); ?>"><img src="<?php echo htmlspecialchars($row['picture'], ENT_QUOTES); ?>"/></a></div>
<?php } ?>
<?php if(!empty($row['name'])){ ?>
<div class="name"><a href="<?php echo htmlspecialchars($row['link'], ENT_QUOTES); ?>"><?php echo htmlspecialchars($row['name'], ENT_QUOTES); ?></a></div>
<?php } ?>
<?php if(!empty($row['caption'])){ ?>
<div class="caption"><?php echo htmlspecialchars($row['caption'], ENT_QUOTES); ?></div>
<?php } ?>
<?php if(!empty($row['description'])){ ?>
<div class="description"><?php echo htmlspecialchars($row['description'], ENT_QUOTES); ?></div>
<?php } ?>
</div>
<?php } ?>
<div class="info<?php if(!empty($row['icon'])){ ?> icon<?php } ?>"<?php if(!empty($row['icon'])){ ?> style="background-image:url('<?php echo htmlspecialchars($row['icon'], ENT_QUOTES); ?>')"<?php } ?>>
<?php echo htmlspecialchars($row['created_time'], ENT_QUOTES); ?><!-- ago -->
</div>
</div>
</div>
<?php
}
}
else {
?><div>No data</div><?php
}
?>
</div>
</div>
<div style="min-height: 100px"></div>
</div>
</div>
<?php else: ?>
<div id="body">
<div class="jumbotron" style="text-align: center; background: none;">
<div class="logo">
<h1 class="welcome">Welcome to</h1>
<img class="logo" src="/beta/assets/img/logo.png">
<h2 class="slogan">Optimize Your Social Status!</h2>
</div>
<div class="intro-text">
<p>Dashboard Here!</p>
</div>
</div>
</div>
<?php endif; ?>
<?php echo View::make('footer')->render() ?>
thats my dashboard.php file.. currently it is pulling the entire user's feed --> i need to filter this out so that it only pulls posts, photos, vids, and pages that user has liked. Does anybody have any ideas? I am stumped.
ty in advance.