2012-05-07 123 views
0

请帮我使用PHP卷曲如何使用PHP卷曲

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

任何帮助将是一个很大的帮助,发布以下多表单数据后置HTML多形式的数据。

+0

虽然它必须是多部分吗? multipart或application/x-www-form-urlencoded应该以​​相同的方式工作。 –

+0

请看看[这里](http://scraperblog.blogspot.com/2013/07/php-curl-multipart-form-posting.html) – pguardiario

回答

1

它的工作原理完全一样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); 
+0

这个例子是不完整/错误的,因为你必须传入一个哈希数组以CURLOPT_POSTFIELDS为它成为一个多部分formpost –

+0

@DanielStenberg:不,如果你有它像这个例子中预格式化,这是没有必要的。 – hakre

0

这样

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

注:阵列中必须全部发布数据。