2011-07-12 43 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);