我有IPTV的URL,产生JSON结果。
网址是(它只有24小时线,所以它会在任何人做任何伤害之前过期)
http://mytv-extra.com:88/player_api.php?username=4240670294&password=0301902562&action=get_live_streams&category_id=3045
字符串
当在浏览器中查看它时,它会显示JSON结果,如下所示
0
num 1
name "##### PL - POLONIA#####"
stream_type "live"
stream_id 400160541
stream_icon "https://lo1.in/pol/flg.png"
epg_channel_id null
added "1620254399"
is_adult null
category_id "3045"
custom_sid "3045"
tv_archive 0
direct_source ""
tv_archive_duration 0
1
num 2
name "PL - TVP 4K"
stream_type "live"
stream_id 117574
stream_icon "https://lo1.in/pol/tvp.png"
epg_channel_id "tvp.pl"
added "1594210172"
is_adult null
category_id "3045"
custom_sid "3045"
tv_archive 0
direct_source ""
tv_archive_duration 0`
型
但是当写cURL来获取结果时,我得到了这个
阵列Copyright © 2018 - 2019 www.cnjs.com. All Rights Reserved.粤ICP备11044552号-1 0 [size_upload] => 0 [size_download]=> 0 [speed_download]=> 0 [speed_upload] => 0 [download_content_length]=>-1 [upload_content_length]=>-1 [starttransfer_time]=> 0 [redirect_time]=> 0 [redirect_url] => [primary_ip] => [certinfo] => Array()[primary_port] => 0 [local_ip][本地端口] => 0 [http_version] => 0 [协议] => 0 [ssl_verifyresult] => 0 [方案] => [appconnect_time_us]=> 0 [连接时间_us]=> 0 [名称查找时间_us] => 5573 [预传输时间_us] => 0 [重定向时间_us]=> 0 [启动传输时间_us]=> 0 [总时间_us] => 1025351) curl 错误:1025毫秒后无法连接到mytv-extra.com端口88:无法连接到服务器
这是我的代码
<?php
$url = "http://mytv-extra.com:88/player_api.php?username=4240670294&password=0301902562& action=get_live_streams&category_id=3045";
ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, $url);
// Set other cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set custom headers, including Access-Control-Allow-Credentials
$headers = [
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',
'Access-Control-Allow-Credentials: true',
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute cURL session and fetch the response
$response = curl_exec($ch);
// Get cURL information for debugging
$info = curl_getinfo($ch);
print_r($info);
// Check for cURL errors
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
echo $response;
}
// Close cURL session
curl_close($ch);
?>
型
我已经成功地创建了不同的网址cURL只是不是这一个,我已经尝试了一切,我可以和在线自上午6时找到答案,即使是人工智能不能帮助。
1条答案
按热度按时间anauzrmj1#
这段代码对我来说很有用:
字符串
请注意,我从URL中删除了空格。在其中有空格时,我会收到一条错误消息。
输出如下所示:
型