Failed to get actual html as a result of JSON when accessing import.io API via cURL

When I access the import api manually in the browser, copying the api-url, I get the correct json result, where the html fields also have html results. However, when I access the same URL via cURL with PHP, I only get this in the following json: {"name":"my_html","type":"HTML"}..so result without actual html.

I use the following function for cURL API in php:

public function queryio($connectorGuid,$url,$input,$userGuid,$apiKey) {

    $io_url = "https://api.import.io/store/data/".$connectorGuid."/_query?input/webpage/url=".urlencode($url)."&_user=" . urlencode($userGuid) . "&_apikey=".$apiKey;

    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$io_url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}

My question is, how can I get the actual html? Btw, everything works fine for other fields like text, date / time, etc.

+4
source share
1 answer

Try to remove

curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
0
source

All Articles