1

I am trying to create a new user subscription using curl, but it seems the parameters never gets sent:

$url = 'http://www.domain.com/user_sub/new';

$curl = curl_init($url);

$curl_post_data = array(
    'email' => '[email protected]',
    'f_name' => 'John',
    'l_name' => 'Doe',
    'zip_code' => 'GB211',
    'promo' => 'promocode'
);

curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($curl_post_data));

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);    

$curl_response = curl_exec($curl);

curl_close($curl);

...

If I do a straight url post over browser it works e.g:

http://www.domain.com/user_sub/[email protected]&f_name=John&l_name=Doe&zip_code=GB211&promo=promocode

What am I doing wrong please?

2
  • if you use: /user_sub/[email protected]&f_name=John&l.. in /user_sub/new change $_POST with $_GET Commented Sep 15, 2016 at 12:26
  • I don't have access to the database and I'm able to get form entries which will populate the array. The url above is supposed to post to a remote system which I have no control over, hence curl. Commented Sep 15, 2016 at 13:13

1 Answer 1

2

have you tried doing it with:

$url = 'http://www.domain.com/user_sub/[email protected]&f_name=John&l_name=Doe&zip_code=GB211&promo=promocode';

        $response = file_get_contents($url, false);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.