function getTopPostEmbedded($id, $type) { switch ($type) { case 'twitter': //Twitter $post = topTweets($id, 1); if (isset($post[0])) { $embed = tweetEmbeed($post[0]->id_str); if (isset($embed->html)) { return $embed->html; } return "<script>console.warn('Twit: " . serialize($embed) . "')</script>"; } else { return "<script>console.warn('Twit: Top post not found')</script>"; } break; case 'facebook': //FB $post = getTopFBPosts($id, 1); if (isset($post[0])) { return FBembeed(getFBlink($post[0])); } else { return "<script>console.warn('FB: Top post not found')</script>"; } break; case 'instagram': $post = getTopIGMedia($id, 1); if (isset($post[0])) { $embed = igEmbed($post[0]->link); return $embed->html; } else { return "<script>console.warn('IG: Top post not found')</script>"; } break; } return null; }
function fbEvents($account, $count = 10) { $events = getTopFBPosts($account, $count); $tevents = array(); if (!isset($events)) { return array(); } foreach ($events as $key => $d) { $teve = array(); $time = strtotime($d->created_time); $sdate = date("l F jS", $time); $teve['title'] = "Post from {$sdate}"; $teve['type'] = "Top Facebook Posts"; $teve['source'] = "Facebook"; $link = getFBlink($d); if ($link) { $teve['html'] = FBembeed($link); $teve['url'] = $link; } else { } $teve['score'] = $key; $teve['points'] = $d->score; $teve['timestamp'] = $time * 1000; //$teve['username'] = $d->from->name; array_push($tevents, $teve); } return $tevents; }