Sunday 15 January 2012

php - Download audio file using cUrl where authentication required to get file -



php - Download audio file using cUrl where authentication required to get file -

i want download sound file server.

when access url direct on server asks username & password want override through curl

basically want allow web users hear songs on website. have authentication of other web so. users of website have double check first login in website using credentials after when click on play button come in 1 time again username & password providing them (of same web have authentication).

$url="https://example.com/abc.wav"; $ch = curl_init(); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_userpwd, "userstring:passstring"); curl_exec($ch); curl_close($ch); direct url after entering username & password allowed me hear audio. how can authenticate web access url overriding authentication? want download , play in background after clicking on button "download" & "play" respectively. on other hand there way can email file without downloading or downloading

use next code authentication forgot set header

header("content-type: audio/mpeg"); $url = "clip.mp3" $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_userpwd, "password"); curl_exec($ch); header('location: ' . $url);

php curl

No comments:

Post a Comment