@@ -5,7 +5,7 @@ class Pnr {
5
5
6
6
7
7
function array2json ($ arr ) {
8
- if (function_exists ('json_encode ' )) return json_encode ($ arr ); //Lastest versions of PHP already has this functionality.
8
+ if (function_exists ('json_encode ' )) return json_encode ($ arr );
9
9
$ parts = array ();
10
10
$ is_list = false ;
11
11
@@ -74,37 +74,27 @@ function makeWebCall($urlto,$postData = null,$refer=null){
74
74
}
75
75
//perform our request
76
76
$ result = curl_exec ($ curl_connection );
77
- // Debug -Data
78
- //show information regarding the request
79
- //var_dump(curl_getinfo($curl_connection));
80
- // echo curl_errno($curl_connection) . '-' .
81
- // curl_error($curl_connection);
82
-
77
+
83
78
//close the connection
84
79
curl_close ($ curl_connection );
85
80
return $ result ;
86
81
}
87
82
88
83
89
- // Function to construct the post request
84
+
90
85
function createPostString ($ postArray ){
91
- //traverse array and prepare data for posting (key1=value1)
86
+
92
87
foreach ( $ postArray as $ key => $ value ) {
93
88
$ post_items [] = $ key . '= ' . $ value ;
94
89
}
95
- //create the final string to be posted using implode()
96
90
return implode ('& ' , $ post_items );
97
91
}
98
92
99
93
100
94
function request ($ pnr )
101
95
{
102
96
103
- // KEY Datatype Mandatory Description
104
- //-------------------------------------------------------
105
- // pnrno Integer(10) true PNR number to be fetched 10 digit
106
- // rtype String(XML/JSON) false Return type format
107
- // callback String false Support for JSONP only supported for GET
97
+
108
98
$ pnt_no = $ pnr ;
109
99
110
100
$ url_captch = 'http://www.indianrail.gov.in/pnr_Enq.html ' ;
@@ -119,9 +109,7 @@ function request($pnr)
119
109
120
110
$ result = $ this ->makeWebCall ($ url_pnr ,$ post_string ,$ url_captch );
121
111
122
- //Debug
123
- //var_dump($result);
124
- // Parse Logic
112
+
125
113
// I have not used DOM lib it is simple regEx parse.
126
114
//Change here when the Page layout of the page changes.
127
115
$ matches = array ();
0 commit comments