2012-01-11 6 views
-1

Spotify 앱에서 mysql 데이터베이스에 연결할 수 있습니까? 필요한 권한에 mysql을 추가했지만 전체 PHP 코드를 보여줍니다. 검색 기능 때문에 mysql을 추가하고 싶다.Spotify 앱용 mysql에 연결

답변

4

PHP는 Spotify Apps에서 지원되지 않습니다. HTML, CSS 및 JavaScript 만 공식적으로 지원됩니다. (Source)

자바 스크립트로 액세스 할 수있는 서버에서 백엔드를 만들 수 있습니다. 당신의 manifest.json

2

앱에서

"RequiredPermissions": [ 
     "http://your.site.com", 
     "http://ajax.googleapis.com", 
      ]

가 서버에

$.getJSON("http://your.site.com/get_variable.php", { "variable": variable }, 
    function(data) { 
     //do something with the returned data 
    } 
).error(function() { console.log("error getting variable"); });

를 추가하여 SQL

$con = mysql_connect("localhost","user_name","password"); 

if (!$con){ 
    die('Could not connect: ' . mysql_error()); 
} 
$db_selected=mysql_select_db("database_name", $con); 

if (!$db_selected){ 
    die ("Can\'t use database_name : " . mysql_error()); 
} 

$variable = $_GET["variable"]; 
$sql = "your sql using $variable" 
$result = mysql_query($sql); 
$search_results=array(); 
while($row = mysql_fetch_array($result)){ 
    //add data from $row into $search_results 
} 
echo json_encode($search_results); 
+0

감사를 수행하는 파일 get_variable.php을 추가! ^^ 이것도 효과가 있습니다! –