$kite = new KiteConnect($zerodha_apikey); // here i have api key
try { $user = $kite->generateSession($zerodha_request_token, $zerodha_secret); // here i have secret key but i don't have request token $kite->setAccessToken($user->access_token); } catch(Exception $e) { echo "Authentication failed: ".$e->getMessage(); throw $e; }
when i run this program with proper input i do not get any response I got error
For now, you can see the usage example here.
it is possible?
I am working on a portal like https://stocksdeveloper.in/
You can write to kiteconnect(at)zerodha.com for compliance related queries.
The issue is not with compliance, now I'm trying to get access token with help of APIs provided in the documentation.
First I'm making API call to get a request token which I'm getting from below snippet.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://kite.zerodha.com/api/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"user_id=########&password=########");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $server_output = curl_exec($ch);
$obj = json_decode($server_output, true);
curl_close ($ch);
Then after getting request token I'm hitting twofa API call to get access token:
echo $data = 'user_id=########&request_id='.$obj['data']['request_id'].'&twofa_value=123456&skip_session=true';
$url = "https://kite.zerodha.com/api/twofa";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Content-Type: application/x-www-form-urlencoded",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
echo $resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
But in response, I'm getting an error:
{"status":"error","message":"Please complete the login before doing 2FA verification.","data":null,"error_type":"UserException"}
Any help will be appreciated !!!!