我正在尝试使用Curl更新Aweber中的一些自定义字段。 当我试图传递postfields时,aweber告诉我我的会话已经过期了。但是我可以在没有这个问题的情况下登录并做其他人员。
也许问题来自于没有表格而且要验证的按钮不是输入类型提交,而是一个有js功能的按钮?不过我看“网络”=> firebug中的XHR和要发送的链接与表单中的所有参数相同。
$str = 'data[submit]=1
&data[Lead][prev_stop_status]=0
&unsubscribe_lead=1
&data[Lead]['.$m.'][name]= name
&data[Lead]['.$m.'][email]='.$email.'
&data[Lead]['.$m.'][note]=control panel
&data[Lead]['.$m.'][datum1]=sdfg
&data[Lead]['.$m.'][datum2]=qsdfqsfd
&data[Lead]['.$m.'][datum3]=sdfgf
&data[Lead]['.$m.'][datum4]=zrtert
&data[Lead]['.$m.'][datum5]=dfgdf
&data[Lead]['.$m.'][name2]=sdfgsgf
&message_old=1
&data[Lead]['.$m.'][message]=1001
&sess_token='.$cookie'
这里$ m对应于铅的ID。
$url ='https://www.aweber.com/users/leads/edit/3266822/'.$m;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_REFERER, 'https://www.aweber.com/users/leads');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$str);
echo curl_exec($ch);
希望足够清楚。我想从fireburg发布一些图片以帮助理解,但我需要更多的声誉点。
有人有想法吗?
编辑:这里是live http header的请求:
POST / users / leads / edit / 3266822/59321794 data%5Bsubmit%5D = 1& data%5BLead%5D%5Bprev_stop_status%5D = 0& unsubscribe_lead = 1& data%5BLead%5D%5B59321794%5D%5Bname% 5D = blacky&安培;数据%5BLead%5D%5B59321794%5D%5Bemail%5D = blackrunnnner%40gmail.com&安培;数据%5BLead%5D%5B59321794%5D%5Bnote%5D = + HF&安培;数据%5BLead%5D%5B59321794%5D %5Bdatum1%5D = stryrtyy&安培;数据%5BLead%5D%5B59321794%5D%5Bdatum2%5D = tttttttttt&安培;数据%5BLead%5D%5B59321794%5D%5Bdatum3%5D = sdsdfsdfsdfs&安培;数据%5BLead%5D%5B59321794%5D%5Bdatum4 %5D = dsfgdsfgd&安培;数据%5BLead%5D%5B59321794%5D%5Bdatum5%5D = ZZZZZZZZZZ&安培;数据%5BLead%5D%5B59321794%5D%5Bname2%5D = lmkmlkllllll&安培; message_old = 1&安培;数据%5BLead%5D%5B59321794%5D %5Bmessage%5D = 1&安培; sess_token = d18b8246230780a51e967326cf687009e9cc2d81
这里是标题:
https://www.aweber.com/users/leads/edit/3266822/59321794
POST / users / leads / edit / 3266822/59321794 HTTP / 1.1
主持人:www.aweber.com
User-Agent:Mozilla / 5.0(Windows NT 6.1; WOW64; rv:25.0)Gecko / 20100101 Firefox / 25.0
接受:text / html, / ; Q = 0.01
接受语言:fr,fr-fr; q = 0.8,en-us; q = 0.5,en; q = 0.3
Accept-Encoding:gzip,deflate
Content-Type:application / x-www-form-urlencoded;字符集= UTF-8
X-Requested-With:XMLHttpRequest
参考者:https://www.aweber.com/users/leads
内容长度:619
Cookie:cookie_aweber_referrer_id = 99; TS8fba11 = 0db6c7090ec415a2a74f5b65b8aeffc52c7ef8b9018afb4c52e3ecfbbd1b0f791761e990; __utma = 121506007.931755370.1390668636.1390668636.1390668636.1; __utmb = 121506007.2.10.1390668636; __utmc = 121506007; __utmz = 121506007.1390668636.1.1.utmgclid = COD4yK_kmbwCFTCWtAod7U4ApA | utmccn =(未%20set)| utmcmd =(未%20set)| utmctr = aweber; _ga = GA1.2.931755370.1390668636; AppCookie [cookie_support] =支撑; TS8fba11_29 = c7dae97d9386c44fe3317a881058edd12c7ef8b9018afb4c00000000000000000052e3eb6c; __ctxpop = 1; AUTORESPSID = d18b8246230780a51e967326cf687009e9cc2d81; AppCookie [顾客] = 1; AppCookie [curlis] = teststeli; KVCD = 1390668716223; km_ai = Km0KWrpCZfFJ0Q7ArZebQRtwxVE%3D; km_uq =; km_vs = 1; km_lv = 1390668716; km_ni = 836900; ki_u = 9560e337-a9a3-16a1-44d0-1060ea2aa10c; ki_t = 1390668681618%3B1390668681618%3B1390668681618%3B1 3B1%
连接:保持活力
Pragma:no-cache
缓存控制:无缓存
数据%5Bsubmit%5D = 1&安培;数据%5BLead%5D%5Bprev_stop_status%5D = 0&安培; unsubscribe_lead = 1&安培;数据%5BLead%5D%5B59321794%5D%5Bname%5D = blacky&安培;数据%5BLead%5D%5B59321794 %5D%5Bemail%5D = blackrunnnner%40gmail.com&安培;数据%5BLead%5D%5B59321794%5D%5Bnote%5D = + HF&安培;数据%5BLead%5D%5B59321794%5D%5Bdatum1%5D = stryrtyy&安培;数据%5BLead%图5D%5B59321794%5D%5Bdatum2%5D = tttttttttt&安培;数据%5BLead%5D%5B59321794%5D%5Bdatum3%5D = sdsdfsdfsdfs&安培;数据%5BLead%5D%5B59321794%5D%5Bdatum4%5D = dsfgdsfgd&安培;数据%5BLead%5D% 5B59321794%5D%5Bdatum5%5D = ZZZZZZZZZZ&安培;数据%5BLead%5D%5B59321794%5D%5Bname2%5D = lmkmlkllllll&安培; message_old = 1&安培;数据%5BLead%5D%5B59321794%5D%5Bmessage%5D = 1&安培; sess_token = d18b8246230780a51e967326cf687009e9cc2d81 < / p>
HTTP / 1.1 200确定
日期:星期六,2014年1月25日17:08:56 GMT
p3p:CP =“NOI ADM DEV PSAi COM NAV OUR STP IND DEM”
Expires:Mon,26 Jul 1997 05:00:00 GMT
Last-Modified:Sat,2014年1月25日17:08:57 GMT
缓存控制:无存储,无缓存,必须重新验证,无缓存
Pragma:no-cache,No-Cache
Vary:Accept-Encoding,User-Agent
内容编码:gzip
内容长度:164
Keep-Alive:timeout = 3,max = 100
连接:Keep-Alive
Content-Type:text / plain
设置Cookie:TS8fba11 = 75ec74303092e39b0609f650ba7394ad2c7ef8b9018afb4c52e3efa8bd1b0f791761e990;路径= /
答案 0 :(得分:0)
你试过吗?
<?php
//debug - remove in production!
error_reporting(E_ALL);
ini_set('display_errors', 1);
//debug end
$str = 'data[submit]=1
&data[Lead][prev_stop_status]=0
&unsubscribe_lead=1
&data[Lead]['.$m.'][name]= name
&data[Lead]['.$m.'][email]='.$email.'
&data[Lead]['.$m.'][note]=control panel
&data[Lead]['.$m.'][datum1]=sdfg
&data[Lead]['.$m.'][datum2]=qsdfqsfd
&data[Lead]['.$m.'][datum3]=sdfgf
&data[Lead]['.$m.'][datum4]=zrtert
&data[Lead]['.$m.'][datum5]=dfgdf
&data[Lead]['.$m.'][name2]=sdfgsgf
&message_old=1
&data[Lead]['.$m.'][message]=1001
&sess_token='.$cookie'
$url ='https://www.aweber.com/users/leads/edit/3266822/'.$m;
$cookies_file = "/tmp/cookie.txt";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_REFERER, 'https://www.aweber.com/users/leads');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
$server_output = curl_exec($ch);
if ($server_output == "OK") {
echo "Post OK";
} else {
echo "Post NOT OK \n";
echo $server_output;
}
?>