Why am I not getting a Json string PHP scraping-ThrowExceptions

Exception or error:

I’m currently working on code to send information to a website, filling out a series oft text blobs, and then then scraping the information back, which comes in the form a json string. I updated my code, and got it to the point where I’m getting an output that is somewhat what I want–but now there is an error code.

<?php
//Ohio
//https://elicense.ohio.gov/oh_verifylicense"
$licenseNum = "";
$isFacility = "1";
$bLicenseId = "022346600";
$bisName = "Ethical factor RX LLC";
$fName = "";
$lName = "";
$mName = "";
$alias = "";
$board = "";
$lType = "";
$lNumber = "";
$city = "";
$county = "";
$bBoard = "";
$bLicenseType = "";
$bcity = "";
$bcounty = "";


$vars = array(
    'firstName' => "",
    'lastName' => "",
    'middleName' => "",
    'contactAlias' => "",
    'board' => "",
    'licenseType' => "",
    'licenseNumber' => "09307888 ",
    'city' => "",
    'state' => "",
    'county' => "",
    'businessBoard' => "",
    'businessLicenseType' => "",
    'businessLicenseNumber' => "",
    'businessCity' => "",
    'businessState' => "",
    'businessCounty' => "",
    'businessName' => "",
    'dbafileld' => "",
    'searchType' => "individual ",

);
$vars = json_encode($vars);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://elicense.ohio.gov/apexremote");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);  //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
    "Accept: */*",
    //"Accept-Encoding: gzip, deflate, br",
    "Accept-Language: en-US,en;q=0.9",
    "Cache-Control: no-cache",
    "Connection: keep-alive",
    //"Content-Length: 886",
    "Content-Type: application/json;charset=UTF-8",
    //"Cookie: _ga=GA1.2.1065923764.1584053639; pctrk=1211f52d-9e86-4e02-a2cd-3c2d5ac90946; _gid=GA1.2.72737056.1584455302",
    "Host: elicense.ohio.gov",
    "Origin: https://elicense.ohio.gov",   
    "Pragma: no-cache",
    "Referer: https://elicense.ohio.gov/oh_verifylicense",


    //"Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private",
    //"Content-Encoding: gzip",
    //"Content-Type: application/json;charset=UTF-8",
    //"Date: Tue, 17 Mar 2020 19:14:22 GMT",
    //"Strict-Transport-Security: max-age=31536004; includeSubDomains",
    //"Transfer-Encoding: chunked",
    //"Vary: Accept-Encoding",
    //"X-Powered-By: Salesforce.com Visualforce",

];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$server_output = curl_exec ($ch);
//var_dump(curl_error($ch));
curl_close ($ch);
print_r($server_output);
print_r(json_decode($server_output));

The error code I’m getting is:
“core.apexpages.exceptions.ApexPagesHandledException:

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *