몇 일 전에 soap API를 사용하여 다른 서버의 내용을 가져 와서 내 자신의 데이터베이스에 결과를 삽입하는 cronjob 스크립트를 코어 PHP에 생성했습니다.cj.com API 호출의 내용 인코딩 오류
이전에는 제대로 작동하여 약 10000 개의 레코드를 가져 와서 데이터베이스에 삽입했습니다.
하지만 이제는 스크립트가 제대로 작동하지 않습니다. 그래서 브라우저 (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.
페이지 인코딩이 변경되고 관련 설정이 거의 없지만 여전히 동일한 오류가 표시됩니다.
또한 코드를 변경하고 아래 코드를 사용했지만 문제가 여전히 있습니다.
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는 약 600 매장 루프 apiCall
방법을 사용하고있다. 해결책을 제안하십시오.
기본적으로 응답이 어떤 식 으로든 손상되었다는 것을 의미합니다. 다른 브라우저에서 확인하고 동일한 오류가 발생하면 curl (헤더 포함) 응답을 가져 와서 해당 정보를 제공하십시오. 또한 서버 측에서 오류가 있는지 확인하고 가능한 경우 서버 자체에서 명령 줄에서 동일한 오류를 실행하십시오. – eis
이 질문은 어떻게 upvote를 얻을 수 있습니까? 진짜 질문을하십시오. – Nin
@eis 늦게 응답하여 죄송합니다. 귀하의 의견에 따라 내 코드를 변경하고 컬 (REST API) 데이터를 가져 오는 있지만 동일한 문제가 여전히 있습니다. 또한 나는 다른 브라우저에서 스크립트를 실행했는데 오류는 보이지 않고 있습니다. mozila만이 "content-encoding-error"를 보여주고 있습니다. 내 질문을 편집 해주세요. –