A
A
Artemy Zheman2015-12-14 18:35:51
PHP
Artemy Zheman, 2015-12-14 18:35:51

Why is the request not being sent?

Good afternoon!
I work through the API of a certain service.
You need to send a request to add a user.
I do so.

<?
$postdata = http_build_query(
    array(
        'api_username' => 'name',
        'api_password' => 'password',
    'MODULE' => 'Customer',
    'COMMAND' => 'add',
    'FirstName' => $_POST['FirstName'],
    'LastName' => $_POST['LastName'],
    'email' => $_POST['email'],
    'Phone' => $_POST['Phone'],
    'campaignId' => '3834',
    'Country' => $_POST['Country'],
    'birthday' => '1980-07-21',
    'gender' => 'male',
    'password' => $_POST['password'],
    'currency' => 'USD',
    'subCampaign' => 'qw'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);

$result = file_get_contents('http://proxy.optionrally.com/api/?', false, $context);

echo $result;
?>

But for some reason, not all fields are sent by the request.
Here is an example of sending a request.
FirstName=Artem&LastName=Name&email=a1rt2349%401gmail.com1&Phone=%2B373345327720&Country=8&password=123123123

The question is, why is it not being sent as expected and why are all the fields missing?
Tried with curl but nothing worked.
If the same request is generated, for example, manually and sent via GET, then everything works and all fields are sent.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2015-12-14
@BuriK666

Specify Content-Length.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question