문제가 있습니다. MySQL 데이터베이스에 저장된 노래를 iTunes 미리보기 API를 사용하여 미리보기 할 수있는 미리보기 노래 버튼을 생성하려고합니다.PHP가 iTunes API로 미리보기 링크를 생성합니다 - SLOW
<?php
// Script de conexión a la base de datos.
include "includes/connect.php";
$songs = "";
$query = $db->prepare("SELECT artista, titulo, nombre, count(id) as uploadCount FROM canciones GROUP BY artista, titulo ORDER BY uploadCount DESC");
$query->execute(array($songs));
$songs = $query->fetchAll(PDO::FETCH_ASSOC);
echo '<table id="tblCanciones" width="95%" border="0" align="center" cellpadding="0">
<tr align="left">
<th class="tblCancionesHeader" width="33%">Artista</th>
<th class="tblCancionesHeader" width="32%">Título</th>
<th class="tblCancionesHeader" width="20%">Pedida por</th>
<th class="tblCancionesHeader" width="10%">Veces</th>
<th class="tblCancionesHeader" width="4%"></th>
</tr>';
foreach($songs as $song) {
// Buscar el link de la preview de la canción en la iTunes store...
$term = urlencode($song["artista"])."+".urlencode($song["titulo"]);
$json = file_get_contents('http://itunes.apple.com/search?term='.$term.'&limit=1&entity=musicArtist,musicTrack,album,mix,song');
$array = json_decode($json, true);
echo '<tr align="left">
<td nowrap="nowrap" class="tblCancionesFila">'.$song["artista"].'</td>
<td nowrap="nowrap" class="tblCancionesFila">'.$song["titulo"].'</td>
<td nowrap="nowrap" class="tblCancionesFila">'.$song["nombre"].'</td>
<td nowrap="nowrap" class="tblCancionesFila">'.$song["uploadCount"].'</td>';
if (!isset($array['results'][0]['previewUrl'])) {
echo '<td nowrap="nowrap" class="tblCancionesFila">---</td>';
} else {
echo '<td nowrap="nowrap" class="tblCancionesFila"><a href="'.$array['results'][0]['previewUrl'].'"><img src="images/imgPreview.jpg" width="20" height="20" alt="preview" title="preview" border="0" /></a></td>';
}
echo '</tr>';
}
echo '</table>';
?>
그것은 몇 가지 제한과 어느 정도 작동합니다
나는 다음과 같은 코드를 작성했습니다. 그냥 미리보기 링크를 가져 와서 결과를 1로 제한하고 싶습니다. 그래서 때때로 결과를 찾지 못합니다 ...
주요 문제는 결과를 가져 오는 데 시간이 오래 걸리며 느립니다. ..
내가 뭔가 잘못하고있는 것 같아.
동일한 기능을 얻는 다른 쉬운 방법이 있을지 모르지만 spotify, soundcloud 또는 기타 같은 itunes 이외의 다른 서비스를 사용하고 있습니까?
감사합니다.
어떻게 PHP를 사용 아이튠즈에서 모든 게임 (응용 프로그램) 정보를 얻을 방법을 가르쳐 주 시겠어요? 나는 찾고 있지만 대답을 얻을 수 없다. 나는 또한 검색 API를 사용 해요. 그러나 나는 그것을 어떻게 사용하는지 몰랐다. 여기 내 질문은 http://stackoverflow.com/questions/23696311/get-game-details-from-itunes-using-php#_=_입니다. –