and*_*szs 0 php xml youtube parsing xml-namespaces
我需要从Feed中获取非常具体的值,例如:
http://gdata.youtube.com/feeds/api/videos/iIp7OnHXBlo
Run Code Online (Sandbox Code Playgroud)
我必须从这些奇怪格式的XML提要中读取的一些节点是:
<title type="text">Uploading YouTube Videos with the PHP Client Library</title>
<media:content url="http://www.youtube.com/v/iIp7OnHXBlo?version=3&f=videos&app=youtube_gdata" type="application/x-shockwave-flash" medium="video" isDefault="true" expression="full" duration="466" yt:format="5"/>
<media:content url="rtsp://v3.cache7.c.youtube.com/CiILENy73wIaGQlaBtdxOnuKiBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="466" yt:format="1"/>
<media:description type="plain">Jochen Hartmann demonstrates the basics of how to use the PHP Client Library with the YouTube Data API. [...]</media:description>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/0.jpg" height="360" width="480" time="00:03:53"/>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/1.jpg" height="90" width="120" time="00:01:56.500"/>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/2.jpg" height="90" width="120" time="00:03:53"/>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/3.jpg" height="90" width="120" time="00:05:49.500"/>
<yt:duration seconds="466"/>
Run Code Online (Sandbox Code Playgroud)
当然,使用Zend Framework API for GData绝对是不可能的(1225个文件和49 MB只是为了解析XML文件?是的,当然......我的主.
我需要使用lastRSS解析器或PHP中的任何内置XML函数,正如他心目中的任何人都会这样.提前感谢任何提示.
几个星期前我遇到了同样的问题.通过添加,?format=5&alt=json
您可以获得JSON格式的回复,然后您可以在PHP中轻松解析
$url = 'http://gdata.youtube.com/feeds/api/videos/iIp7OnHXBlo?format=5&alt=json';
$response = file_get_contents($url);
$obj = json_decode($response);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3448 次 |
最近记录: |