我正在努力将简单的动作从enfmp标记器发送到echonest-server。
PHP代码
$file =file_get_contents('./test.json');
$jsondecode = json_decode($file,true );
foreach($jsondecode as $puffer) {
$result = $puffer['code'];
}
$post = array(
"api_key"=>"=MYAPIKEY",
"version"=>"=3.15",
"code"=>"=$result",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "http://developer.echonest.com/api/v4/song/identify");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$json_response = curl_exec($ch);
$response = json_decode($json_response, true);
响应是
["response"]=>
array(1) {
["status"]=>
array(3) {
["version"]=>
string(3) "4.2"
["code"]=>
int(1)
["message"]=>
string(22) "1|Invalid key: Unknown"
}
}
}
API Key正常运行。 有人可以查看代码并给我一些提示或示例吗?
问候:)