1

Please help me to post the following multipart form data using PHP cURL

url = "http://smssheep.com/sendsms.php";
reffer="http://smssheep.com/";

POSTDATA =-----------------------------187161971819895
Content-Disposition: form-data; name="country"

0091
-----------------------------187161971819895
Content-Disposition: form-data; name="no"

00918714349616
-----------------------------187161971819895
Content-Disposition: form-data; name="msg"

hggggggggggggggggggggggggggggggggggggggggg
-----------------------------187161971819895
Content-Disposition: form-data; name="x_form_secret"

bqu9hv488bxu
-----------------------------187161971819895
Content-Disposition: form-data; name="saveForm"

SEND
-----------------------------187161971819895
Content-Disposition: form-data; name="comment"


-----------------------------187161971819895
Content-Disposition: form-data; name="idstamp"

Ds11xxs27YzNm/r/vf I rmQbz2TS1yaMNXeuHD6ozI=
-----------------------------187161971819895--

Any help will be a great help.

2
  • Does it have to be multipart though? Either multipart or application/x-www-form-urlencoded should work in the same way. Commented May 7, 2012 at 9:55
  • Please have a look here Commented Jul 10, 2013 at 12:30

3 Answers 3

1

It works exactly like explained in the PHP manual:

$data = 'url = "http://smssheep.com/sendsms.php";
reffer="http://smssheep.com/";

POSTDATA =-----------------------------187161971819895
Content-Disposition: form-data; name="country"

...

Ds11xxs27YzNm/r/vf I rmQbz2TS1yaMNXeuHD6ozI=
-----------------------------187161971819895--'

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
Sign up to request clarification or add additional context in comments.

2 Comments

this example is incomplete/wrong as you must pass in a hash array to CURLOPT_POSTFIELDS for it to become a multi-part formpost
@DanielStenberg: No, if you have it pre-formatted like in this example, this is not necessary.
1

http://php.net/manual/en/function.curl-setopt.php

CURLOPT_POSTFIELDS

Comments

1

like this

$url = "http://smssheep.com/sendsms.php";
$reffer="http://smssheep.com/";
$data = array(
        'country' => '0091',
        'no' => '00918714349616',
        'msg' => 'hggggggggggggggggggggggggggggggggggggggggg'       
        );


$data2 = http_build_query($data);

curl_setopt ($ch, CURLOPT_URL,$url); 
curl_setopt ($ch, CURLOPT_POST, 1); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data2); 
curl_setopt ($ch, CURLOPT_REFERER, $reffer);         

note: in the array must be all post data.

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.