Few days before I created a cronjob script in core php for fetching contents from other server with soap API and inserting the result in to my own database.
Previously it was working fine and fetching around 10000 records and inserting them in to database.
But now the script dosen't work properly. So I executed the script in browser(Mozila) and it gives me this error.
Content Encoding Error:
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression. Please contact the web site owners to inform them of this problem.
I changed the page encoding and few ini related settings but it still showing the same error.
I also changed my code and using below code but the problem is still there.
class API
{
protected $developerKey;
protected $websiteId;
// Intialise all the values
public function __construct(){
$this->developerKey = 'XXXXXXX';
$this->websiteId = "yyyyyy";
}
public function apiCall($storeId,$start)
{
try
{
$url = "https://linksearch.api.cj.com/v2/link-search?";
$url .="website-id=".$this->websiteId;
$url .="&advertiser-ids=".$storeId;
$url .="&link-type=".urlencode('Text Link');
$url .="&page-number=".$start;
$url .="&records-per-page=100";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: '.$this->developerKey));
$curl_results = curl_exec($ch);
$xml = simplexml_load_string($curl_results);
$json = json_encode($xml);
$arrres = json_decode($json,TRUE);
return $arrres;
}
catch (Exception $e)
{
return $e->getMessage();
}
}
}
I am using apiCall
method in a loop for around 600 stores.
Please suggest any solution.
Basically, content encoding error means the response was corrupted in some way, so it couldn't be rendered. IT could've been issue with just one browser, but since you're getting this with curl:
it means that this is no browser issue, something has gone awry on the server side. You need server logs, especially error logs, to diagnoze this further. Something has happened on the server side, but the information presented doesn't even hint as to what would that be.