コード例 #1
0
ファイル: Api.php プロジェクト: brianvoss/brianvossdotcom
 /**
  * Add X-Client-IP to all requests
  * Whitelisted API keys only
  */
 public static function addClientIP($ip = null)
 {
     if (empty($ip)) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     if (empty(self::$headers)) {
         self::$headers = array("X-Client-IP: " . $ip);
     } else {
         $newHeaders = array();
         foreach (self::$headers as $header) {
             if (strpos($header, 'X-Client-IP:') !== 0) {
                 $newHeaders[] = $header;
             }
         }
         $newHeaders[] = "X-Client-IP: " . $ip;
         self::$headers = $newHeaders;
     }
 }
コード例 #2
0
 public function favoritesAction()
 {
     $this->api->getUserInfo();
 }
コード例 #3
0
 public function getSongs($fetch = true)
 {
     if ($this->songs || !$fetch) {
         return $this->songs;
     }
     $this->songs = parent::getPlaylistSongs($this->getPlaylistID());
     return $this->songs;
 }
コード例 #4
0
ファイル: Search.php プロジェクト: brianvoss/brianvossdotcom
 private static function performSearch($method, $query, $country = null, $max = null)
 {
     $results = array();
     for ($page = 1; $page <= 2; $page++) {
         switch ($method) {
             case "getSongSearchResults":
                 $searchResults = parent::getSongSearchResults($query, $country, $max ? $max : 91, ($page - 1) * 90);
                 break;
             case "getArtistSearchResults":
             case "getAlbumSearchResults":
                 $searchResults = call_user_func(array(parent::getInstance(), $method), $query, $max ? $max : 91, ($page - 1) * 90);
                 break;
             default:
                 return false;
                 break;
         }
         if ($searchResults === false || count($searchResults) < 1) {
             break;
         }
         if (count($searchResults) > 90 && (!$max || $max > 100)) {
             array_pop($searchResults);
             //we need to check if there are more results
         }
         self::appendResults($searchResults, $results);
         if (count($searchResults) < 90 || $max && count($results) > $max) {
             break;
         }
     }
     if ($max) {
         return array_slice($results, 0, $max, true);
     } else {
         return $results;
     }
 }
コード例 #5
0
ファイル: User.php プロジェクト: brianvoss/brianvossdotcom
 private function getUserIDFromUsername($username = null)
 {
     if ($username) {
         $this->setUsername($username);
     }
     if ($this->getUsername()) {
         $return = parent::apiCall('getUserIDFromUsername', array('username' => $this->getUsername()));
         if (isset($return['decoded']['result']['UserID'])) {
             $this->setUserID((int) $return['decoded']['result']['UserID']);
             return $this->userid;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }