我創造了./application/helpers自定義的助手但我收到此錯誤定製傭工笨
無法加載請求的文件助手/ curl_helper
這是代碼我的幫助文件:
function send(array $request, $url, $method)
{
//Validating if the required extensions are installed or not
if(!function_exists('json_encode')) return false;
if(!function_exists('curl_init')) return false;
//Converting the array into required json format
$request = json_encode($request);
//Setting header required for requests
$header[] = "Content-type: application/json";
$header[] = "Content-length: ".strlen($request) . "\r\n";
//If the request method is get append the data into requests header
if($method == 'GET' or $method == 'get') $header[] = $request;
//Initializing curl
$ch = curl_init();
//Setting curl options for request
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
//If the request method is post add the data we need to enable post
//request and define the data in post fields
if($method == 'POST' or $method == 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
}
//Executing the curl request and storing the result in a variable
$result = curl_exec($ch);
//Closing curl conneciton
curl_close($ch);
return json_decode($result);
}
,我加載它在我的圖書館,如:
$this->loader =& get_instance();
$this->loader->load->helper('curl');
告訴我我在哪裏做錯了?
UPDATE:
嘗試了太多的事情,當我在同一個庫把功能,我想用我發現,在該線路的錯誤後
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
當我評論這個線功能正常工作。我不知道錯誤在哪裏,請幫助我。就我認爲這是裝載機錯誤的原因。
你給你的助手'curl_helper.php'命名了嗎? – 2012-03-12 14:42:10
Offcourse和我已經嘗試在任何方式意味着通過前綴子類前綴和刪除它。 – 2012-03-12 14:43:18
嘗試它沒有加載器'$ this-> load-> helper('curl');' – 2012-03-12 14:45:21