Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. virenk1984
    3. Posts
    V
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Groups 0

    Posts made by virenk1984

    • AG8004 Error Code while fetching market rates using php curl

      I am using the following code, but I am getting following response. Please help me out.

      Response:

      stdClass Object ( [success] => [message] => Invalid API Key [errorCode] => AG8004 [data] => )


      Code:

      $URL = "https://apiconnect.angelbroking.com/rest/secure/angelbroking/market/v1/quote/";

      $ch = curl_init($URL);
      $header = array();
      $header[] = 'X-PrivateKey: '.$APIKEY_market;
      $header[] = 'Accept: application/json, application/json';
      $header[] = 'X-SourceID: WEB, WEB';
      $header[] = 'X-ClientLocalIP: '.$_SERVER['REMOTE_ADDR'];
      $header[] = 'X-ClientPublicIP: '.$_SERVER['REMOTE_ADDR'];
      $header[] = 'X-MACAddress: MAC_ADDRESS';
      $header[] = 'X-UserType: USER';
      $header[] = 'Authorization: Bearer '.$JwtToken;
      $header[] = 'Content-Type: application/json';
      
      $str = json_encode(array("mode"=>"LTP","exchangeTokens"=>array("NFO"=>array("150200"))));
      curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POST, 1);
      // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
      curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
      //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
      //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
      $rest = curl_exec($ch);
      curl_close($ch);
      
      curl_close($ch);
      $result_arr = json_decode($rest);
      print_r($result_arr);
      

      posted in Test
      V
      virenk1984