这是我随便抓的一个接口地址:http://interface.yy.com/hls/get/0/54880976/54880976?appid=0&excid=1200&type=m3u8&callback=jsonp2
输出后文本如下
jsonp2({"code":0,"hls":"http://hls.yy.com/newlive/54880976_54880976.m3u8?org=yyweb&appid=0&uuid=b09929c952f34f059f1c637a7de4f3be&t=1482754694&tk=08dbec696bb3a17c03a4472bf9ae5993&uid=0&ex_audio=0&ex_coderate=1200&ex_spkuid=0"})
我想取里面这段连接地址:
我使用组数获取不知道哪里错了?麻烦帮忙看看修改一下谢谢!
$url="http://interface.yy.com/hls/get/0/54880976/54880976?appid=0&excid=1200&type=m3u8&callback=jsonp2";
$json=json_decode($url,true);
$str=$json["code"]["hls"];
echo $str;exit;
How to get the specified content in the following interface through php? -PHP Chinese website Q&A-How to get the specified content in the following interface through php? -PHP Chinese website Q&A
Please watch and learn.
截图:
<?php
$url="http://interface.yy.com/hls/get/0/54880976/54880976?appid=0&excid=1200&type=m3u8&callback=jsonp2";
$data=str_replace('})','}',str_replace('jsonp2({','{',file_get_contents($url)));
$json=json_decode($data,true);
$str=$json["hls"];
echo $str;
exit;
那是jsonp接口,建议使用js接收,可以在js中定义个jsonp2函数,json数据就是参数。