如何使用API查看Xtream代码2.9.2中的行?

问题描述 投票:0回答:2

如何从 Xtream Code CMS 查看线路?

我正在使用一些 API,但无法查看行,它总是显示“访问被拒绝”。 如何允许API访问?我有 Xtream 代码 2.9.2 版本。 我知道要使用 API,我们必须从常规设置 -> API 设置将我们的 IP 地址导入白名单。这是 Xtream 代码 2.3.x 中的一个选项,但在更高版本中,他们进行了更改。默认情况下,他们已禁用 API 的访问。我们当前版本的 Xtream 代码中没有此类选项。 有什么解决办法吗?如何在 Xtream 代码 2.9.2 中允许 API 访问?

<?php
$panel_url = 'https://cms.xtream-codes.com/xxxx/'; //i am giving my cms xtream code panel link here

$username = "xxxx";  //i am giving my xtream code cms username here
$password = "xxxx";  //i am giving my xtream code cms password here


##############################################################################
$post_data = array( 'username' => $username, 'password' => $password );
$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=info", false, $context ), true );
echo  implode( ',', $api_result);
?>

访问被拒绝

php video-streaming live-streaming iptv
2个回答
0
投票

非常确定 $panel_url 指的是您的主服务器的 URL,而不是您的 cms 面板


0
投票

我使用 xtream-codes V2 API 检查活动订阅信息的解决方案 为您的表单创建一个 Index.php 页面

<form class="form-inline"  action="submit.php" method="post">

    <div class="form-group">
      <input type="text" class="form-control" id="username" placeholder="Enter Lines Username" name="username">
      <input type="text" class="form-control" id="password" placeholder="Enter Lines Password" name="password">
    <button type="submit" id="submit" class="btn btn-primary" name="submit">GET STREAM IDS</button>
</form>

创建

submit.php
并将表单操作指向它

 <?php
$surname = $_POST['surname'];
$username = $_POST['username'];
$password = $_POST['password'];
$exp_date = date("d-m-Y",$json['user_info']["exp_date"]);



$json = json_decode(file_get_contents("http://<-YOUR DNS ->:<-YOUR PORT ->/panel_api.php?username=$username&password=$password"), true);
?>

<?php echo $json['user_info']["username"];?></a>
<?php echo $json['user_info']["password"];?></a>
<?php echo $json['user_info']["status"];?></a>
<?php echo $exp_date;?></a>

and create a line download button like this
  <a href="http://<-YOUR DNS ->:<-YOUR PORT ->/get.php?username=<?php print $json['user_info']["username"];?>&password=<?php print $json['user_info']["password"];?>&type=m3u_plus&output=ts" class="btn btn-primary">DOWNLOAD PLAYLIST</a>

下面的代码将生成一个活动频道表及其 TS 编号,具体取决于输入的线路订阅包

<table>
    <thead>
      <tr>
        <th width="50%"><center>STREAM NAME</center></th>
        <th width="50%"><center>STREAM TS NUMBER</center></th>
      </tr>
    </thead>
    <tbody>
      <tr>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$json = json_decode(file_get_contents("http://<-YOUR DNS ->:<-YOUR PORT ->/player_api.php?username=$username&password=$password&action=get_live_streams"), true);
for ($x = 0; $x < count($json); $x++)
{ ?>


<td><center><strong><?php echo $json[$x]['name'];?></strong></center></td>

<td><center><strong><?php echo $json[$x]['stream_id'];?></strong></center></td>
</tr>
<?php } ?>

这些可能不是最好的方法,但它们有效,而且我自己也在用

© www.soinside.com 2019 - 2024. All rights reserved.