Example #1
0
 public static function getAppId()
 {
     if (self::$appid) {
         return self::$appid;
     }
     $file = dirname(__FILE__) . '/MBLApplicationId.txt';
     if (is_readable($file)) {
         self::$appid = file_get_contents($file);
         if (!is_string(self::$appid)) {
             throw new Exception('No valid application ID found');
         }
         return self::$appid;
     }
     throw new Exception("Make sure {$file} is readable");
 }
Example #2
0
 public function newWithMe()
 {
     $data = $this->fetch('newwithme');
     $output = array();
     if (!is_array($data)) {
         return $output;
     }
     foreach ($data['event'] as $entry) {
         $row = array();
         $row['site'] = $entry['name'];
         $row['time'] = MBLApplication::ago(strtotime($entry['created_at']));
         switch ($entry['name']) {
             case 'twitter':
                 $row['content'] = $entry['message'];
                 $row['source'] = 'http://twitter.com/' . $entry['username'];
                 break;
             case 'flickr_latest':
                 $row['site'] = 'flickr';
                 $row['content'] = '<a href="' . $entry['image_link'] . '" class="flickrd"><img src="' . $entry['thumbnail_src'] . '" alt="' . $entry['title'] . '"></a>';
                 $row['source'] = 'http://flickr.com/photos/' . $entry['username'] . '/';
                 break;
             case 'delicious':
                 $row['content'] = '<a href="' . $entry['url'] . '">' . $entry['title'] . '</a>';
                 $row['content'] .= '<p>' . $entry['description'] . '</p>';
                 $row['source'] = 'http://delicious.com/' . $entry['username'];
                 break;
             case 'youtube':
                 $row['content'] = '<a href="' . $entry['url'] . '" class="vid"><img src="' . $entry['thumbnail_url'] . '" alt="' . $entry['title'] . '"></a>';
                 $row['source'] = 'http://youtube.com/' . $entry['username'];
                 break;
             case 'lastfm':
                 $track = urldecode(substr($entry['url'], strrpos($entry['url'], '/') + 1));
                 $row['content'] = 'Listened to <a href="' . $entry['url'] . '">' . $track . '</a> by ' . $entry['artist'];
                 $row['source'] = 'http://last.fm/user/' . $entry['username'];
                 break;
             case 'netflix':
                 $row['content'] = '<a href="' . $entry['url'] . '">' . $entry['title'] . '</a>';
                 break;
             default:
                 continue 2;
                 // $row['content'] .= '<br><pre>' . print_r($entry, 1) . '</pre>';
                 break;
         }
         $output[] = $row;
     }
     return $output;
 }