在发出两个 cURL 请求后,第二个请求我想捕获返回的 HTML 并将其作为字符串传递回调用函数。现在它改为将 HTML 输出到客户端。我搞砸了ob_end_clean()
,也ob_get_contents()
没有成功。
这是我目前拥有的...
function stuff()
{
//user/pass stuff omitted.
$ch = curl_init();
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookies);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=$cp_user&pass=$cp_pwd");
curl_setopt($ch,CURLOPT_TIMEOUT,100020);
ob_start();
$f = curl_exec($ch);
$h = curl_getinfo($ch);
$p0 = explode('cpsess',$h['url']);
$p1 = explode('/',$p0[1]);
ob_end_clean();
/***/
ob_start();
curl_setopt($ch,CURLOPT_URL,$q2a.$p1[0].$q2b);
curl_setopt($ch,CURLOPT_HEADER, 0);
curl_exec($ch);
$r = ob_get_contents();
ob_end_clean();
/***/
curl_close($ch);
return $r;
}