无法解析主机'www.youtube.com

时间:2013-08-25 15:54:57

标签: php curl

$curl = curl_init("http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=Bgn7n3OPAqE&format=json");
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$ret = json_decode(curl_exec($curl),true);
print_r($ret);
 $err     = curl_errno( $curl );
$errmsg  = curl_error(  $curl);
echo $err; echo $errmsg;
curl_close($curl);
嘿,我试图在youtube api中获取内容,但我说无法解决,但当我尝试通过终端它返回我的数组

1 个答案:

答案 0 :(得分:0)

在嵌入url地址之前尝试删除“o”,即

http://www.youtube.com/embed?url=https://www.youtube.com/watch?v=Bgn7n3OPAqE&format=json