Login issue PHP curl


  • I am trying to login but it keep on giving me error code 400. Not sure why? Below is my code
    Also in header I am not sure what to set as MAC IP as I don't hold mac and in client local ip I am adding my system local IP and in client public ip I am adding my server ip where my website is located.
    I hope i am doing it right..

    $headers = array('Content-Type: application/json', 'Accept: application/json', 'X-UserType: USER', 'X-SourceID: WEB', 'X-ClientLocalIP: 182.69.96.96', 'X-ClientPublicIP: 185.28.21.157', 'X-MACAddress: MYMACIP', 'X-PrivateKey: MYPRIVATEKEY');

        $data["clientcode"] = "MYCLIENTCODE";
        $data["password"] = "PASSWORD";
    
        $url = 'https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword';
    
        $jsonData = json_encode($data);
    
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            
        $result = curl_exec($curl);
        $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    
        echo '<br/>Response Status : ' . $http_status;
        echo '<br/>Response String : ' . $result;
    
        //To Convert json response to array
        $resJsonArray = json_decode($result, true);
    

    Response I am receiving is

    Response Status : 400
    Response String :


  • Sir kindly migrate my account user id A587355