function query($url, $pfields = 0, $cookie = 0)
{
curl_setopt($ch, CURLOPT_HEADER, 1);
if (!empty($pfields))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $pfields);
}
if (!empty($cookie))
{
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING,'gzip');
if (!$login)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
}
$content = curl_exec($ch);
return $content;
}
$cookie = 'sessionID=3864cab58412ec567b634db3c317898;OAGEO=RU%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C;';
$p = '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++';
$post = 'clientid=23&campaignid=52&bannerid=111&appendsave=1&appendtype=0&append=' . urlencode($p) . '&submitbutton=';
echo query('http://example.com/in.php', $post, $cookie);
此代碼返回417錯誤( 但$ p不是使用進行urlencode,但確定的,但正(+)爲「「(空格)PHP CURL POST請求和錯誤417
Sooooorry變革我非常糟糕的英語
理論上你的代碼可以/應該工作,和417是保留給一個錯誤的'Expect'頭,你不發送服務器本身可能。行爲不端行爲d嘗試通過使用'curl_setopt($ ch,CURLOPT_VERBOSE,1)來獲得額外的數據爲什麼它失敗;' – Wrikken 2010-09-20 21:57:07
Curl自動將它添加爲「大」的帖子。某些服務器,如lighttpd,不支持它。 – Matthew 2010-09-20 22:23:32