Reputation: 49
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.
Upvotes: 1
Views: 14338
Reputation: 42
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.
Upvotes: 1
Reputation: 3635
http://php.net/manual/en/function.curl-setopt.php
CURLOPT_POSTFIELDS
Upvotes: 1
Reputation: 198214
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);
Upvotes: 1