Skip to content

Commit 39c1315

Browse files
committed
fix: place order example in readme is fixed
1 parent c256a3d commit 39c1315

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,43 @@ Download `kiteconnect.php` and `include()` it in your application.
1515
## Usage
1616
```php
1717
<?php
18-
include dirname(__FILE__)."/kiteconnect.php";
19-
20-
// Initialise.
21-
$kite = new KiteConnect("your_api_key");
22-
23-
// Assuming you have obtained the `request_token`
24-
// after the auth flow redirect by redirecting the
25-
// user to $kite->login_url()
26-
try {
27-
$user = $kite->generateSession("request_token_obtained", "your_api_secret");
28-
29-
echo "Authentication successful. \n";
30-
print_r($user);
31-
32-
$kite->setAccessToken($user->access_token);
33-
} catch(Exception $e) {
34-
echo "Authentication failed: ".$e->getMessage();
35-
throw $e;
36-
}
37-
38-
echo $user->user_id." has logged in";
39-
40-
// Get the list of positions.
41-
echo "Positions: \n";
42-
print_r($kite->getPositions());
43-
44-
// Place order.
45-
$order_id = $kite->placeOrder("regular", [
46-
"tradingsymbol" => "INFY",
47-
"exchange" => "NSE",
48-
"quantity" => 1,
49-
"transaction_type" => "BUY",
50-
"order_type" => "MARKET",
51-
"product" => "NRML"
52-
])["order_id"];
53-
54-
echo "Order id is ".$order_id;
18+
include dirname(__FILE__)."/kiteconnect.php";
19+
20+
// Initialise.
21+
$kite = new KiteConnect("your_api_key");
22+
23+
// Assuming you have obtained the `request_token`
24+
// after the auth flow redirect by redirecting the
25+
// user to $kite->login_url()
26+
try {
27+
$user = $kite->generateSession("request_token_obtained", "your_api_secret");
28+
29+
echo "Authentication successful. \n";
30+
print_r($user);
31+
32+
$kite->setAccessToken($user->access_token);
33+
} catch(Exception $e) {
34+
echo "Authentication failed: ".$e->getMessage();
35+
throw $e;
36+
}
37+
38+
echo $user->user_id." has logged in";
39+
40+
// Get the list of positions.
41+
echo "Positions: \n";
42+
print_r($kite->getPositions());
43+
44+
// Place order.
45+
$o = $kite->placeOrder("regular", [
46+
"tradingsymbol" => "INFY",
47+
"exchange" => "NSE",
48+
"quantity" => 1,
49+
"transaction_type" => "BUY",
50+
"order_type" => "MARKET",
51+
"product" => "NRML"
52+
]);
53+
54+
echo "Order id is ".$o->order_id;
5555
?>
5656
```
5757

0 commit comments

Comments
 (0)