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 topTweetEvents($account, $count = 10) { $tweets = topTweets($account, $count); if (!isset($tweets)) { return array(); } $tevents = array(); foreach ($tweets as $key => $t) { $teve = array(); $time = strtotime($t->created_at); $sdate = date("l F jS", $time); $ebed = tweetEmbeed($t->id_str); $teve['title'] = "Tweet from {$sdate}"; $teve['type'] = "Top Tweets"; $teve['source'] = "Twitter"; if (isset($ebed->html)) { $teve['html'] = $ebed->html; } else { $teve['html'] = "<script>console.warn('Twit: " . serialize($ebed) . "')</script>"; } $teve['score'] = $key; $teve['url'] = "https://twitter.com/statuses/" . $t->id_str; $teve['points'] = $t->score; $teve['timestamp'] = $time * 1000; // $teve['username'] = '******' . $t->user->screen_name; array_push($tevents, $teve); } return $tevents; }