Help: Style data after getting it from Facebook Graph API

Started on the old forum in May 2011 · view the original in the archive · old links redirect here

7 replies · 598 views · started 15 years ago · 1 min read

3 participants
Mysterio Lead · 630 posts #1

Hello all,

as said on Facebook Developers page, pointing your browser at http://graph.facebook.com/ervis.mysterio/feed will get my Facebook feeds.

Anyone has a script or a clear logic how to style this data? I am trying many ways with PHP expressions but no result till now... And time passes fast...

(p.s.: No suggestion to use secret key please, because I need this way)

mysterio.al - programming is a functional art

CreativityKills Lead · 833 posts #2

i assume u already knw hw to get the stream so heres what u can do:

<table>
<?php
$data = $facebook->api('/me?limit=10');
foreach($data as $k => $v){
 $pic = '<img src="'.arrGet($v, 'picture', 'no_photo.jpg').'"/>';
 $full_name = arrGet($v['from'], 'name', 'No name');
 $msg = arrGet($v, 'message');
 $link = arrGet($v, 'link', FALSE);
 $link = $link ? '<a href="'.$link.'">'.arrGet($v, 'name', $link).'</a>' : null;
 $desc = arrGet($v, 'description', null);
 $caption = arrGet($v, 'caption', null);
 $likes = arrGet($v, 'likes', FALSE);
 $likes = $likes ? arrGet($v['likes'], 'count') : 'No';
 $cmts = arrGet($v, 'comments', FALSE);
 $cmts = $cmts ? arrGet($v['comments'], 'count') : 'No';
?>
<tr>
<td><?=$pic ?></td>
<td colspan="2">
<?=$full_name ?> <?=$msg ?><br />
<?=$link ?><br />
<?php echo $caption ? $caption.'<br/>' : null ?>
<?=$desc ?><br/>
<div align="right">
<?=$likes.' Likes' ?> | <?=$cmts.' Comments' ?>
</div>
</td>
</tr>
<?php
}
?>
</table>
CreativityKills Lead · 833 posts #3

Then add the arrGet function:

function arrGet(array $array, $key, $default = null){
return (isset($array[$key]) AND ! empty($array[$key])) ? $array[$key] : $default;
}
Mysterio Lead · 630 posts #4

CreativityKills wrote: i assume u already knw hw to get the stream so heres what u can do:

I really don't know how you mean. Intsead of learning something, I only get more confused.

Can it be fetched using Graph API. I can't understand the "access token" yet...

mysterio.al - programming is a functional art

CreativityKills Lead · 833 posts #5

Download the facebook php sdk from github, it takes care of everything on the inside, all you have to do is make calls and it adds the tokens simple.

Ponick Developer · 216 posts #6

If u use fb sdk u may have to enter ur secret key 😛

/* I don't know everything hehe */

Find me on facebook

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close