0
這裏是我的代碼,我不斷收到同樣的錯誤響應消息「:」有一個錯誤處理請求「」堆棧跟蹤「:」」,‘ExceptionType’ - JQUERY
"{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}"
。我無法弄清楚,我使用Eloqua API來獲取基本信息,例如帳戶總數,登錄頁面,用戶,圖像等等。這很奇怪,因爲我在POSTMAN應用程序上嘗試了API並且它確實工作正常Screenshot of postman response to the API
PHP
$objetos = array("data/accounts", "data/contacts", "assets/emails", "assets/landingPages", "assets/images", "assets/forms", "system/users", "assets/microsites", "assets/customObjects");
for ($i = 0; $i < 9; $i++){
$url = 'http://secure.p03.eloqua.com/API/REST/1.0/' . $objetos[$i] . '?count=1';
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
$headers = array(
'Content-type: application/json',
'Authorization: BASIC "MY TOKEN"'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() ."/EloquaApi_lvl1.cer");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
$data[$i] = curl_exec($ch);
curl_close($ch);
}
echo json_encode($data);
?>
JS
function getObjetos(){
$.get("objetos.php", function (data) {
console.log(data);
}, "json").done(function (data) {
console.log(data);
// rest of my code
}
控制檯 console.log response (click for image)
您可以添加請求和響應從PHP到Eloqua?正文+標題+狀態碼... –