1

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.

Ravi Kant Mishra
  • 778
  • 1
  • 7
  • 13
  • 2
    It means basically that the response was corrupted in some way. Please, check with some other browser and if you get the same error, fetch the response with curl (with headers) and supply that information. Also, check for any errors on the server side, and if possible try to execute the same in command line on the server itself. – eis Sep 27 '12 at 08:41
  • How can this question get any upvote? Please ask a real question. – Nin Sep 27 '12 at 19:59
  • @eis Sorry for the late response. As per your comment I changed my code and fetching the data with curl (REST API) but the same problem is still there. Also I executed my script on other browsers they are not showing any error only mozila is showing "content-encoding-error". I have edited my question please have a look. – Ravi Kant Mishra Sep 29 '12 at 04:23
  • @RaviKantMishra you are saying other brwosers are not showing any error. does that mean that the thing works for other browsers? or just that they don't show the error? – eis Oct 01 '12 at 14:50
  • @eis They just don't show the errors. It is getting break on any random place during execution. My script works well when I execute it in 2 or 3 steps but that I don't want. Also as per your previous comment you said "supply that information" what does it mean. – Ravi Kant Mishra Oct 02 '12 at 04:34
  • @RaviKantMishra it meant that if you could run curl using command line with -v option and copy the output to here. Also, I meant curl instead of the browser, not curl in your script. With -v it would show the header traffic. However, if this behaviour is browser independent and the script just don't work, it seems to be a problem with the script itself, and that you haven't shown to us. – eis Oct 02 '12 at 05:59
  • @RaviKantMishra and about the errors on the server side, was there any? – eis Oct 02 '12 at 06:00
  • @eis here is the result which I got after executing my script with curl -v option. I have also edited the question and pasted my script. Also I don't have access to view server error log so sorry for that. `< HTTP/1.0 500 Internal Server Error` `< Date: Thu, 04 Oct 2012 16:08:03 GMT` `< Server: Apache` `< Content-Length: 581` `< Content-Type: text/html; charset=iso-8859-1` `< X-Cache: MISS from p3nlhproxy003.shr.prod.phx3.secureserver.net` `< X-Cache-Lookup: MISS from p3nlhproxy003.shr.prod.phx3.secureserver.net:3128` `< Connection: close` – Ravi Kant Mishra Oct 04 '12 at 16:55
  • I am unable to understand this header result. I really appreciate your efforts on this issue. – Ravi Kant Mishra Oct 04 '12 at 17:21
  • @RaviKantMishra added as an answer. Basically, it says *something* is going wrong on the server side. No more, no less. – eis Oct 04 '12 at 17:47

1 Answers1

0

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:

HTTP/1.0 500 Internal Server Error

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.

eis
  • 51,991
  • 13
  • 150
  • 199
  • I checked my server error log. But its empty. I think there might be some problem with `cj.com web services`. Anyways thanks for comments. – Ravi Kant Mishra Oct 12 '12 at 05:09