我正在使用来自提供者的网络服务,该提供者正在对进行太有助于预测我的需求。他们给了我一个HTML片段来粘贴在我的网站上,供用户点击触发他们的服务。我宁愿编写这个过程的脚本,所以我有一个php脚本,将cURL请求发布到相同的URL,如适用。但是,此提供程序正在查看我的会话,并将每个新请求解释为第一个请求的更新,而不是每个都是唯一的请求。尝试使用cURL避免ASP.NET会话
关于我的问题,我已经联系了提供商,他们竟然告诉我他们的系统按预期工作,并且我不可能避免每个人都使用相同的ASP.NET会话随后的cURL请求。虽然我最喜欢的选择是切换到不同的供应商,但目前看来这不是一种选择。有没有一种可靠的方式来获得每个cURL请求的新ASP.NET会话?
我尝试了以下一组CURLOPT的的,都无济于事:
//initialize curl
$ch = curl_init($url);
//build a string out of the post_vars
$post_str = http_build_query($post_vars);
//set the necessary curl options
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "UZ_".uniqid());
curl_setopt($ch, CURLOPT_REFERER, CURRENT_SITE_URL."index.php?newsession=".uniqid());
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Pragma: no-cache", "Cache-Control: no-cache"));
//execute the call to the backend script, retrieve the results
$xmlstr = curl_exec($ch);
您是否尝试过手动将'CURLOPT_COOKIE'设置为空字符串?或者可能指定'CURLOPT_COOKIEFILE'和'CURLOPT_COOKIEJAR',并在请求之间解除文件链接? – grossvogel 2010-08-29 16:03:09