我正在尝试使用PHP curl代理播放.m3u8视频。以下code不起作用:
<?php
//http://127.0.0.1/m3u8.php
//....proxy info
$auth = 'username:password';
$proxy_ip = '1.2.3.4.5';
$proxy_port = 8080;
$path = $_GET['link'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $auth);
curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
echo $error_msg;
}
curl_close($ch);
if (isset($error_msg)) {
echo $error_msg;
}
?>
页面返回“格式错误的格式错误”错误,有什么办法可以解决此问题?
谢谢