Skip to content

Commit aef32a3

Browse files
committed
FIx generateSession method
1 parent 4d3a4f1 commit aef32a3

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

kiteconnect.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@
5454
print_r($kite->getPositions());
5555
5656
// Place order.
57-
$order_id = $kite->placeOrder([
57+
$o = $kite->placeOrder([
5858
"tradingsymbol" => "INFY",
5959
"exchange" => "NSE",
6060
"quantity" => 1,
6161
"transaction_type" => "BUY",
6262
"order_type" => "MARKET",
6363
"product" => "NRML"
64-
], "regular")["order_id"];
64+
], "regular");
6565
66-
echo "Order id is ".$order_id;
66+
echo "Order id is ".$o->order_id;
6767
</pre>
6868
6969
A typical web application
@@ -108,7 +108,6 @@ class KiteConnect {
108108
"api.token" => "/session/token",
109109
"api.token.invalidate" => "/session/token",
110110
"api.token.renew" => "/session/refresh_token",
111-
"api.token.renew.invalidate" => "/session/refresh_token",
112111
"user.profile" => "/user/profile",
113112
"user.margins" => "/user/margins",
114113
"user.margins.segment" => "/user/margins/{segment}",
@@ -252,12 +251,12 @@ public function generateSession($request_token, $api_secret) {
252251
"checksum" => $checksum
253252
]);
254253

255-
if(!empty($resp->access_token)) {
254+
if($resp->access_token) {
256255
$this->setAccessToken($resp->access_token);
257256
}
258257

259-
if(!empty($resp->last_time)) {
260-
$resp->last_time = new DateTime($resp->last_time);
258+
if($resp->login_time) {
259+
$resp->login_time = new DateTime($resp->login_time);
261260
}
262261

263262
return $resp;
@@ -851,7 +850,7 @@ private function _request($route, $method, $params=null) {
851850
}
852851

853852
// Prepare the payload.
854-
$payload = http_build_query($params);
853+
$payload = http_build_query($params ? $params : []);
855854
$headers = "Accept-Language: en-US,en;q=0.8\r\n" .
856855
"Accept-Encoding: gzip, deflate\r\n" .
857856
"Accept-Charset: UTF-8,*;q=0.5\r\n" .

0 commit comments

Comments
 (0)