几天前,我在core中创建了一个cronjob脚本,用于使用soap从其他服务器获取内容,并将结果插入到我自己的数据库中。
在此之前,它运行良好,获取了大约10000条记录,并将它们插入数据库。
但现在剧本不能正常工作了。所以我在browser(Mozila)中执行了这个脚本,它给了我这个错误。
内容编码错误: 无法显示要查看的页,因为它使用无效或不受支持的压缩形式。请与网站所有者联系,告知他们这个问题。
我更改了页面编码和一些ini相关设置,但仍然显示相同的错误。
我还修改了我的代码,并使用了下面的代码,但问题仍然存在。
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();
}
}
}我在一个循环中为大约600个商店使用apiCall方法。请提出任何解决方案。
发布于 2012-10-04 17:47:14
基本上,内容编码错误意味着响应以某种方式损坏,因此无法呈现。只需要一个浏览器就可以解决这个问题,但是既然您是通过curl获得这个问题的:
HTTP/1.0 500内部服务器错误
这意味着这不是浏览器问题,服务器端出了问题。需要服务器日志,特别是错误日志来进一步诊断这一点。服务器端发生了一些事情,但是所提供的信息甚至没有暗示会发生什么。
https://stackoverflow.com/questions/12614890
复制相似问题