Php 卷曲柱-所需长度
我已经做了一个简单的代码登录到我的网站Php 卷曲柱-所需长度,php,cookies,curl,http-status-code-411,Php,Cookies,Curl,Http Status Code 411,我已经做了一个简单的代码登录到我的网站 private function request($url, $reset_cookies, $post_data) { $options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, CURLOPT_FAIL
private function request($url, $reset_cookies, $post_data)
{
$options = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HEADER => 0,
CURLOPT_FAILONERROR => 1,
CURLOPT_USERAGENT => $this->user_agent,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_MAXREDIRS => 10,
CURLOPT_AUTOREFERER => 1,
CURLOPT_COOKIESESSION => $reset_cookies ? 1 : 0,
CURLOPT_COOKIEJAR => $this->session_id,
CURLOPT_COOKIEFILE => $this->session_id,
);
// Add POST data
if (isset($post_data))
{
$options[CURLOPT_CUSTOMREQUEST] = 'POST';
$options[CURLOPT_POST] = 1;
$options[CURLOPT_POSTFIELDS] = http_build_query($post_data);
}
// Attach options
curl_setopt_array($this->curl, $options);
// Execute the request and read the response
$content = curl_exec($this->curl);
// Handle any error
if (curl_errno($this->curl)) throw new Exception(curl_error($this->curl));
return $content;
}
因此,基本上,我的登录系统的正常步骤是:
$postdata = array(
'login' => $login,
'password' => $password,
'__RequestVerificationToken' => $security_token,
);
$login_page = $this->browser->request('https://mysite.com/login', false, $postdata);
我是做错了什么,还是忘记设置参数了?解决方案是删除这一行
$options[CURLOPT_CUSTOMREQUEST] = 'POST';
你看了吗:@Mike是的,我已经看过那些页面了。我没有找到任何解决方案我忘了说我在两个请求中使用了同一个Curl实例。*你研究过吗?即使我做了一个POST请求,我也会遇到同样的问题。所以我不认为multi_exec能解决这个问题。
$options[CURLOPT_CUSTOMREQUEST] = 'POST';