Regarding kite to laravel connect

durgeshpandey215
hi, i am trying to connect but am not able to.

$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

  • rakeshr
    Currently, we haven't added laravel supported package. We will be adding this soon.
    For now, you can see the usage example here.
  • durgeshpandey215
    I need an API where I can create my own portal for my client.
    it is possible?

    I am working on a portal like https://stocksdeveloper.in/
  • sujith
    @durgeshpandey215,
    You can write to kiteconnect(at)zerodha.com for compliance related queries.
  • durgeshpandey215
    Hi Sujith,

    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 !!!!

  • rakeshr
    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=########");
    You are using wrong kite connect login URL. You can refer to complete kite connect url login flow here.
  • durgeshpandey215
    can you help me to develop this programm
  • rakeshr
    You will have to subscribe to Kite connect APIs to use this feature.
This discussion has been closed.