Getting curl_error(): 2 is not a valid cURL handle resource while fetching all users from freshdesk api

梦想的初衷 提交于 2019-12-03 04:27:53
Michael Sivolobov

You use curl_errno and curl_error after closing $ch. It is not right.

You need to close your $ch after fetching information about error.

echo curl_errno($ch);
echo curl_error($ch);
curl_close($ch);

Also you didn't set anything to $ch_result. If you expect that it contains result of your request you are wrong. To fix this you need to add option CURLOPT_RETURNTRANSFER and fetch the result with $ch_result = curl_exec($ch);

Won Jun Bae
echo curl_errno($ch);
echo curl_error($ch);

must be called before curl_close($ch);

You use curl_errno and curl_error after closing $ch. It is not right.

You need to close your $ch after fetching information about error.

thats true i get answer this .

        $data = curl_exec($ch);
        if (!curl_errno($ch)) {
         ....
        }
        curl_close($ch);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!