接口请求地址
请求URL地址: http://silk2mp3.wlphp.com/api.php
上传音频
上传音频
支持.silk格式
1、视频大小尽量保持在10M以内。
2、支持.silk格式。
php调用实例:
header("Content-Type: text/html; charset=UTF-8");
$filename = "0.silk";
$data['file'] = "@" . dirname(__FILE__) . "/file/" . $filename;
$url = "http://silk2mp3.wlphp.com/api.php"; //接口地址
$cOntent= curlPost($url, $data); //通过curl发送数据到接口
print_r($content);
/**
* @param $url 发送post请求的url
* @param $data 发送的数据
* @return mixed
*/
function curlPost($url, $data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); //Problem (2) in the Chunked-Encoded data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
@curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); //php5.6.0开始,需要加上这行代码方可上传,否则取不到文件
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
$errorno = curl_errno($ch);
if ($errorno) {
$rt['sta'] = "0";
$rt['msg'] = "curl错误:$errorno";
return json_encode($rt);
die;
}
return $tmpInfo;
}
返回实例:
{
"sta": 1,
"msg": "ok",
"url": "http://silk2mp3.wlphp.com/mp3/0.mp3"
}