我正在燈堆棧上從頭開始構建我的第一個項目。我決定嘗試一下slim api框架。下面你可以看到我開始爲我的API創建一個輔助函數。但是我得到這個未定義常量CURLOPT_GET - 假定'CURLOPT_GET'
錯誤:未定義的常量CURLOPT_GET - 假設 'CURLOPT_GET'
,然後這個
錯誤:curl_setopt()預計參數2長,串給出
// Main Gospel Blocks API Call Function
Function gbCall($gbRoute) {
// JSON Headers
$gblCallHeaders[] = "Content-Type: application/json;charset=utf-8";
// Call the API
$gblCall = curl_init();
curl_setopt($gblCall, CURLOPT_URL, $GLOBALS['gbApiUrl'] . $gbRoute);
curl_setopt($gblCall, CURLOPT_GET, TRUE);
curl_setopt($gblCall, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($gblCall, CURLOPT_HTTPHEADER, $gblCallHeaders);
// Get the response
$response = curl_exec($gblCall);
// Close cURL connection
curl_close($gblCall);
// Decode the response (Transform it to an Array)
$response = json_decode($response, true);
// Return response
return $response;
}
我打的api只是json編碼的對象,不太清楚爲什麼這不返回json ...
燁那絕對固定它它發生。 –