2011-07-12 42 views
0

這是以下形式:發佈的形式使用CURL PHP

<textarea name="message" id="messageContent" rows="18" wrap="virtual" tabindex="2"></textarea> 

    <span id="formSubmit"> 
<a href="#" class="formSubmit" tabindex="3"> 
<img src="/clear.gif" class="master-sprite sprite-pm-send"> 
</a> 
    </span> 

的formSubmit類是一個Ajax函數I追查的源代碼中,我使用的Fiddler捕獲我需要POST的PARAMS,發現這個:

callCount=1 
c0-scriptName=PostFunctions 
c0-methodName=insertPost 
c0-id=1894_1310435282892 
c0-param0=number:1578007 
c0-param1=string:Hello%20World! 
xml=true 

Hello World!是我在textarea上寫的貼子,小提琴手也在頭上找到了一個cookie,不確定是否需要使用它。有人可以幫忙嗎?我正在嘗試將這個帖子發佈2天,這真的讓我發瘋了!感謝

+0

你是什麼意思「的formSubmit類是一個Ajax功能」是什麼意思? formSubmit只是HTML元素的類屬性。 – bcoughlan

+0

我不知道,我只是迷失在那裏,我只是在學習捲曲,在這種情況下,它不是一個常規的形式,沒有「提交」按鈕,你能幫助我嗎? –

回答

0

請求的頁面和拆分在HTTP頭的Cookie響應 例子:

//get the cookies 
$ch = curl_init("url"); 
$opts = array(
     CURLOPT_RETURNTRANSFER => true, 
     CURLOPT_HEADER => true 
      ); 

curl_setopt_array($ch, $opts); 
$res = curl_exec($ch); 
preg_match_all("/set-cookie:\s*([^\n]+)/i",$res,$cookies); 
$cookies = implode(";", $cookies[1]); 

//send the post with cookies in headers 
$ch = curl_init("url"); 
$opts = array(
     CURLOPT_RETURNTRANSFER => true, 
     CURLOPT_HEADER => true, 
     CUOROPT_COOKIE => $cookies, 
     CURLOPT_POST => true, 
     CURLOPT_POSTFIELDS => $params 
      ); 

curl_setopt_array($ch, $opts); 
$res = curl_exec($ch);