无法运行此PHP脚本

时间:2015-07-19 11:42:37

标签: php

在下面的代码中,我试图获得PNR状态的结果

但不知道如何正确使用它来调用函数

网址 - https://github.com/ankitpise/OpenIrctc

错误 - 内部服务器错误

<?php

include 'OpenIrctc.php';

$irctc = new OpenIrctc(6643704951); // $pnr_number = null by default
$irctc->set_language(); // english / hindi. English by default

$irctc->pnr_full_check(6643704951); // not necessary to pur $pnr number if initiated library with it.

$status= json_decode($data);
print_r($status);
var_dump($status);

?>

1 个答案:

答案 0 :(得分:1)

您的500错误可能是由于没有声明$data

像这样使用它:

include 'OpenIrctc/OpenIrctc.php';

$irctc = new OpenIrctc(6643704951);
$irctc->set_language('hindi');
$data = $irctc->pnr_full_check();
print_r($data); 

此外,该脚本不会返回json(pnr_full_check()调用reader_array()并返回一个数组)

这是输出:

Array
(
    [6643704951] => Array
        (
            [status] => success
            [train_info] => Array
                (
                    [train_no] => 13287
                    [train_name] => साउथबिहार एक्स.
                    [train_date] => 24- 7-2015
                    [train_from] => टाटानगर जं.
                    [train_to] => BIHA
                    [train_res_to] => BIHA
                    [train_res_from] => टाटानगर जं.
                    [train_res_class] => तृतीय वातानुकूलित
                )

            [यात्री 1] => Array
                (
                    [booking_status] => W/L    8,RLGN  
                    [current_status] => W/L    8
                )

            [चार्ट तैयार नहीं ] => Array
                (
                    [charting_status] => W/L    8
                )

        )

)