Skip to content

Commit fbc3406

Browse files
author
swaraj
committed
better documentation
1 parent 3e99486 commit fbc3406

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
##A Laravel Package for PNR Enquiry through Indian Railways
1+
##A Laravel Package for PNR Enquiry PHP API through Indian Railways
22

33

44
>Note:- This is not intended for any DOS attack, just to ease the Automation of PNR enquiry through Laravel
55
66
PNR Enquiry for Laravel
77

88
Add swarajsaaj/pnr to composer.json.
9+
```php
10+
11+
"require-dev": {
12+
"swarajsaaj/pnr": "dev-master"
13+
}
914

10-
"swarajsaaj/pnr": "dev-master"
15+
```
1116

12-
Run <code>composer update</code> to pull down the latest version.
17+
Run <code>composer update --dev</code> to pull down the latest version.
1318

1419
Now open up app/config/app.php and add the service provider to your providers array.
1520

src/Swarajsaaj/Pnr/Pnr.php

+6-18
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Pnr {
55

66

77
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);
99
$parts = array();
1010
$is_list = false;
1111

@@ -74,37 +74,27 @@ function makeWebCall($urlto,$postData = null,$refer=null){
7474
}
7575
//perform our request
7676
$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+
8378
//close the connection
8479
curl_close($curl_connection);
8580
return $result;
8681
}
8782

8883

89-
// Function to construct the post request
84+
9085
function createPostString($postArray){
91-
//traverse array and prepare data for posting (key1=value1)
86+
9287
foreach ( $postArray as $key => $value) {
9388
$post_items[] = $key . '=' . $value;
9489
}
95-
//create the final string to be posted using implode()
9690
return implode ('&', $post_items);
9791
}
9892

9993

10094
function request($pnr)
10195
{
10296

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+
10898
$pnt_no = $pnr;
10999

110100
$url_captch = 'http://www.indianrail.gov.in/pnr_Enq.html';
@@ -119,9 +109,7 @@ function request($pnr)
119109

120110
$result = $this->makeWebCall($url_pnr,$post_string,$url_captch );
121111

122-
//Debug
123-
//var_dump($result);
124-
// Parse Logic
112+
125113
// I have not used DOM lib it is simple regEx parse.
126114
//Change here when the Page layout of the page changes.
127115
$matches = array();

0 commit comments

Comments
 (0)