您好,我想使用CURL在網站上發佈一些數據。發佈過程有3個步驟。 1.輸入一個網址,提交併進入第二步,某些字段已經完成 2.再次提交,輸入更多數據並預覽表格後。 3.提交最終數據。curl multipart /表單數據幫助
的問題是,在第二步驟之後,表單數據看起來像這樣
POSTDATA =-----------------------------12249266671528
Content-Disposition: form-data; name="title"
Filme 2010, filme 2009, filme noi, programe TV, program cinema, premiere cinema, trailere filme - CineMagia.ro
-----------------------------12249266671528
Content-Disposition: form-data; name="category"
3
-----------------------------12249266671528
Content-Disposition: form-data; name="tags"
filme, programe tv, program cinema
-----------------------------12249266671528
Content-Disposition: form-data; name="bodytext"
Filme 2010, filme 2009, filme noi, programe TV, program cinema, premiere cinema, trailere filme
-----------------------------12249266671528
Content-Disposition: form-data; name="trackback"
-----------------------------12249266671528
Content-Disposition: form-data; name="url"
http://cinemagia.ro
-----------------------------12249266671528
Content-Disposition: form-data; name="phase"
2
-----------------------------12249266671528
Content-Disposition: form-data; name="randkey"
9510520
-----------------------------12249266671528
Content-Disposition: form-data; name="id"
17753
-----------------------------12249266671528--
我被困試圖設計一個算法,將產生這樣的POST數據的第二步。只需提及表單的URL就不會改變。它總是:http://www.xxx.com/submit。只有一個被稱爲「相位」的隱藏輸入根據我當前所處的步驟(相位= 1,相位= 2,相位= 3)而改變。任何幫助,無論是代碼,僞代碼或只是指導將不勝感激。
我迄今爲止代碼:
function postBlvsocialbookmarkingcom($curl,$vars) {
extract($vars);
$baseUrl = "http://www.blv-socialbookmarking.com/";
//step 1: login
$curl->setRedirect();
$page = $curl->post ($baseUrl.'login.php?return=/index.php', array ('username' => $username, 'password' => $password, 'processlogin' => '1', 'return' => '/index.php'));
if ($err = $curl->getError()) {
return $err;
}
//post step 1----
//get random key
$page = $curl->post($baseUrl.'/submit', array());
$randomKey = explode('<input type="hidden" name="randkey" value="',$page);
$randKey = explode('"',$randomKey[1]);
//-------------------------------------
$page = $curl->post($baseUrl.'/submit', array('url'=>$address,'phase'=>'1','randkey'=>$randKey[0],'id'=>'c_1'));
if ($err = $curl->getError()) {
return $err;
}
//echo $page;
//
//post step 2
$page = $curl->post ($baseUrl.'/submit', array ('title' => $title, 'category'=>'1', 'tags' => $tags, 'bodytext' => $description, 'phase' => '2'));
if ($err = $curl->getError()) {
return $err;
}
echo $page;
//post step 3
$page = $curl->post ($baseUrl.'/submit', array ('phase' => '3'));
if ($err = $curl->getError()) {
return $err;
}
echo $page;
}
你能粘貼你的代碼嗎? – MANCHUCK 2010-04-05 15:10:15
我編輯了我原來的帖子,看看。 – user253530 2010-04-05 15:15:25