Jump to content

johnman

New Members
  • Posts

    8
  • Joined

  • Last visited

johnman's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. Good day I will like to get customers credit details in my app after inputer the required parameters through the form input. After inputing the required values in the form fields and clicking the submit button the response was json with key but null value. My Code // Collection object $data = [ 'BVN' => $_POST["customerBVN2"], 'SessionCode' => $_POST["sessionCode2"], ]; $url = "https://api2.creditregistry.com/nigeria/AutoCred/v7.Test/api/Reports/GetData2"; // Initializes a new cURL session $curl = curl_init($url); // Set the CURLOPT_RETURNTRANSFER option to true curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Set the CURLOPT_POST option to true for POST request curl_setopt($curl, CURLOPT_POST, true); // Set the request data as JSON using json_encode function curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); // Set custom headers for RapidAPI Auth and Content-Type header curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ]); // Execute cURL request with all previous settings $response = curl_exec($curl); // Close cURL session curl_close($curl); echo $response . PHP_EOL; Error response {"Success":false,"Errors":["Invalid request. ReportDataRequest property of the GetDataRequest2 object cannot be null. Expected object format is: \r\n {\r\n \"SessionCode\": \"\",\r\n \"ReportDataRequest\": {\r\n \"BVN\": \"\",\r\n \"AccountOwnerIDs\": \"\",\r\n \"HistoryLengthInMonths\": 84,\r\n \"SectorExclusionIDs\": \"\",\r\n \"IncludeSMARTScore\": false,\r\n \"IncludePDFReport\": false,\r\n \"PDFReportType\": 110,\r\n \"Reason\": \"General credit inquiry\",\r\n \"GetNoMatchReport\": 0\r\n }\r\n}"],"SMARTScores":[],"Accounts":[],"PerformanceSummary":{"Inquiry_Count_12_Months":null,"Count_AccountStatus_Closed":null,"Count_AccountStatus_Delinquent_30_over_60_days":null,"Count_AccountStatus_Derogatory_120_days":null,"Count_AccountStatus_Derogatory_150_days":null,"Count_AccountStatus_Derogatory_Doubtful_180":null,"Count_AccountStatus_Derogatory_Lost_360":null,"Count_AccountStatus_Derogatory_Substandard_90":null,"Count_AccountStatus_Late_less_than_30_days":null,"Count_AccountStatus_Open":null,"Count_AccountStatus_Performing":null,"Count_AccountStatus_Unknown":null,"Count_AccountStatus_Unspecified":null,"Count_AccountStatus_Written_off":null,"Count_LegalStatus_Judgment":null,"Count_LegalStatus_Litigation":null,"Count_LegalStatus_Notice":null,"Count_LegalStatus_Receivership":null,"SelfInquiriesLast12Months":null,"DishonouredChequesLast12Months":null},"AccountSummaries":[],"PDFReport":{"Success":true,"Errors":[],"PDFContent":"","NoMatchPDFContent":"","ReportNo":"","Filename":"","StatusCode":200,"Message":""},"StatusCode":400,"Message":"Invalid request. ReportDataRequest property of the GetDataRequest2 object cannot be null."} Kindly help
  2. @requinix thanks you for your reply i will rewrite the code
  3. I edited the above code because the API endpoint is not included, it has been included in the below code $mydata = array( 'number1' => $_POST["customerNUM1"], 'number2' => $_POST["sessionNUM1"], ); $headers = array( 'Content-Type' => 'application/json' ); $url = "https://api2.creditregistry.com/nigeria/AutoCred/v7.Test/api/Customers/FindByBVN2"; $ch = curl_init($url); // curl_setopt($ch,CURLOPT_COOKIEJAR, $this->cookie_jar); // curl_setopt($ch,CURLOPT_COOKIESESSION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, False); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, False); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($ch,CURLOPT_MAXREDIRS,0); curl_setopt($ch,CURLOPT_TIMEOUT,30); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $err = curl_error($ch); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
  4. Good day I tried getting a json response using the below written code but instead it returned the following error message {"Message":"The request entity's media type 'multipart/form-data' is not supported for this resource."} see the code below $mydata = array( 'number1' => $_POST["customerNUM1"], 'number2' => $_POST["sessionNUM1"], ); $headers = array( 'Content-Type' => 'application/json' ); $ch = curl_init($url); // curl_setopt($ch,CURLOPT_COOKIEJAR, $this->cookie_jar); // curl_setopt($ch,CURLOPT_COOKIESESSION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, False); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, False); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($ch,CURLOPT_MAXREDIRS,0); curl_setopt($ch,CURLOPT_TIMEOUT,30); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $err = curl_error($ch); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } Kindly help
  5. Good day I have written a php code that allows users to login to a dashboard successfully and works fine. Right now i want the code to return and display response on the next page i.e dashboard when logged into dashboard see the code below $data = array( 'EmailAddress' => 'john@mail.com', 'Password' => '1234567890', ); $url = "https://website.com/Login.php"; $nextPage = "dashboard.php"; $options = array( 'http' => array( 'method' => 'POST', 'content' => json_encode( $data ), 'header'=> "Content-Type: application/json\r\n" . "Accept: application/json\r\n" ) ); $context = stream_context_create( $options ); $result = file_get_contents( $url, false, $context ); $response = json_decode( $result, true ); //echo $result; to see the result remove comment and add comment to header('Location: '.$nextPage); if ($response["Message"] !== "The request is invalid." && $response["Authenticated"]) { echo "login successfull"; header('Location: '.$nextPage); } else { echo "login failed!"; } Kindly help
  6. Good day I am developing a project that requires me to consume/connect to an API for login and registration of users on my website. I know how to develop login and registration pages on my own server/database but i have not used a third party webservice/API to implement. I will be grateful if i can be pointed to a tutorial or a help guide that can solve this challenge Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.