我正在尝试打开远程URL:
使用fopen
$ url ='https://pinecast.com/listen/f352578b-955b-4b2e-8c51-e5ef6a0630df.mp3?source=rss&aid=e2958985-cebc-4cfa-808e-d6001730d485.mp3';
$ file = fopen($ url,'rb');
我得到了
<b>Warning</b>: fopen(https://pinecast.com/listen/f352578b-955b-4b2e-8c51-e5ef6a0630df.mp3?source=rss&aid=e2958985-cebc-4cfa-808e-d6001730d485.mp3): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
具有卷曲:
$outFileName= dirname(__FILE__) . '/file.mp3';
$options = array(
CURLOPT_FILE => fopen($outFileName, 'w'),
CURLOPT_TIMEOUT => 28800, // set this to 8 hours so we dont timeout on big files
CURLOPT_URL => $url
);
$ch = curl_init();
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
使用curl可以下载文件,但可以下载0字节