Answer the question
In order to leave comments, you need to log in
Is it possible to implement the task with curl?
Hello everyone, please help me solve this problem.
There is a php code:
$curl = curl_init('http://sitename');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "Username:Password");
curl_exec($curl);
curl_close($curl);
Order deny,allow
Deny from all
AuthType Basic
AuthUserFile /www/.htpasswd
AuthName "Protected Area"
require valid-user
Allow from 127.0.0.1
<video>
<source src="http://sitename/filename.mp4">
</video>
Answer the question
In order to leave comments, you need to log in
Firstly, if the authorization was unsuccessful, 401 Unathorized will be returned, you can do something like this
$curl = curl_init('http://sitename');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "Username:Password");
curl_exec($curl);
$httpCode = curl_getinfo($curl,CURLINFO_HTTP_CODE);
if($httpCode == 401){
//failed
}else{
//maybe success?
}
curl_close($curl);
$curl = curl_init('http://sitename');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "Username:Password");
curl_setopt($curl,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
if(!strpos("<video",$response)){
//fail
}else{
//success
}
curl_close($curl);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question