Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP CURL post request and Error 417

Tags:

php

curl

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);

This code is returned 417 error( BUT $p is not usage urlencode but IS OK but +(plus) change for " "(space)

Sooooorry for my very bad english

like image 911
Isis Avatar asked Sep 20 '10 21:09

Isis


People also ask

When to use HTTP status 417?

The HTTP Status Code 417 means that the server cannot meet the requirements of the Expect request-header field.

What is status 417?

The HTTP 417 Expectation Failed client error response code indicates that the expectation given in the request's Expect header could not be met.

What is Curlopt_verbose?

CURLOPT_VERBOSE. true to output verbose information. Writes output to STDERR , or the file specified using CURLOPT_STDERR . value should be an int for the following values of the option parameter: Option.


1 Answers

Try adding this:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
like image 89
Matthew Avatar answered Sep 30 '22 13:09

Matthew