Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Error in login in php

    General Discussion
    0
    1
    0
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Hrishi_95 last edited by

      Screenshot 2025-03-10 233546.png

      <form method='post' action=''>
            <input type="text" name="otp">
            <input type="submit" name="totp">
      
         </form>
      
      <?php
      if(isset($_POST['totp'])){
      $api_key = "";
      $client_id = "";
      //$client_secret = "YOUR_CLIENT_SECRET";
      $password = "";
      $totp = $_POST['otp']; // If enabled
      
      $state = "YOUR_STATE";
      $client_local_ip = "YOUR_CLIENT_LOCAL_IP";
      $client_public_ip = "YOUR_CLIENT_PUBLIC_IP";
      $mac_address = "YOUR_MAC_ADDRESS";
      
      // SmartAPI Login URL
      $login_url = "https://apiconnect.angelone.in/rest/auth/angelbroking/user/v1/loginByPassword";
      
      // Login Payload
      $login_data = [
          "clientcode" => $client_id,
          "password" => $password,
          "totp" => $totp,
          "state" => $state
      ];
      
      // Headers
      $headers = [
          "Content-Type: application/json",
          "Accept: application/json",
          "X-UserType: USER",
          "X-SourceID: WEB",
          "X-ClientLocalIP: $client_local_ip",
          "X-ClientPublicIP: $client_public_ip",
          "X-MACAddress: $mac_address",
          "X-PrivateKey: $api_key"
      ];
      
      // cURL Request
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $login_url);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($login_data));
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      $response = curl_exec($ch);
      curl_close($ch);
      
      // Handle Response
      $response_data = json_decode($response, true);
      print_r($response_data); // Prints API response
      
      }
      ?>
      
      

      please help me how to do the login with MPIN

      1 Reply Last reply Reply Quote 0
      • First post
        Last post