简体   繁体   English

cj.com API调用中的内容编码错误

[英]Content Encoding Error in cj.com API Call

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. 在几天前,我在核心php中创建了cronjob脚本,以便使用soap API从其他服务器获取内容并将结果插入到我自己的数据库中。

Previously it was working fine and fetching around 10000 records and inserting them in to database. 以前,它运行良好,可以获取大约10000条记录并将其插入数据库。

But now the script dosen't work properly. 但是现在脚本无法正常工作。 So I executed the script in browser(Mozila) and it gives me this error. 所以我在浏览器(Mozila)中执行了脚本,它给了我这个错误。

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. 我更改了页面编码和一些与ini相关的设置,但仍显示相同的错误。

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. 我在大约600家商店的循环中使用apiCall方法。 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可能只用一个浏览器就存在问题,但是由于您使用curl了,因此:

HTTP/1.0 500 Internal Server Error HTTP / 1.0 500内部服务器错误

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. 服务器端发生了一些事情,但是显示的信息甚至没有暗示那是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM