0
我想问一下在youtube上创建新广播后生成的xml文件,我需要使用PHP获取此文件,而无需登录到YouTube,使用php获取Flash Media Encoder xml配置文件
我已经不喜欢的东西
public function cURLcheckBasicFunctions()
{
if(!function_exists("curl_init") &&
!function_exists("curl_setopt") &&
!function_exists("curl_exec") &&
!function_exists("curl_close")) return false;
else return true;
}
/*
* Returns string status information.
* Can be changed to int or bool return types.
*/
public function cURLdownload($url, $file)
{
if(!$this->cURLcheckBasicFunctions()) return "UNAVAILABLE: cURL Basic Functions";
$ch = curl_init();
if($ch)
{
$fp = fopen($file, "w");
if($fp)
{
if(!curl_setopt($ch, CURLOPT_URL, $url))
{
fclose($fp); // to match fopen()
curl_close($ch); // to match curl_init()
return "FAIL: curl_setopt(CURLOPT_URL)";
}
if(!curl_setopt($ch, CURLOPT_FILE, $fp)) return "FAIL: curl_setopt(CURLOPT_FILE)";
if(!curl_setopt($ch, CURLOPT_HEADER, 0)) return "FAIL: curl_setopt(CURLOPT_HEADER)";
if(!curl_exec($ch)) return "FAIL: curl_exec()";
curl_close($ch);
fclose($fp);
return "SUCCESS: $file [$url]";
}
else return "FAIL: fopen()";
}
else return "FAIL: curl_init()";
}
public function testXmlFile(){
$xml= 'https://www.youtube.com/livestreaming?source=primary&itag=33&v=CtAsVo0Mug0&action_fmle_profile=1';
echo $this->cURLdownload($xml, "test.xml");
}
但这总是返回空文件,但如果我把网址,过去它在浏览器中同时登录到YouTube上的文件下载OK