我正在尝试使用cURL以异步方式使用回调来执行请求.我正在使用从网站复制的一段代码.
当我在浏览器中写这个url:http://www.myhost:3049/exemplo/index/async /它执行执行curl_post函数的函数asyncAction.
/**
* Send a POST requst using cURL
* @param string $url to request
* @param array $post values to send
* @param array $options for cURL
* @return string
*/
function curl_post($url, array $post = NULL, array $options = array())
{
$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 4,
CURLOPT_POSTFIELDS => http_build_query($post)
);
$ch = curl_init();
curl_setopt_array($ch, ($options …Run Code Online (Sandbox Code Playgroud)