Wordpress模块:Visual Form Builder
我需要将帖子值发送给我的一个 网站与视觉形式建设者。
基本上我有这个网站供人们填写,何时填写 用户提交表单,我的网站也会发送 使用可视化表单构建器将数据发送到我的网站。
我现在已经敲了两天头。 仍然无法使其发挥作用。
*我正在使用php CURL。我检查过cookies,csrf隐藏字段。等等......仍然没有运气......
P.S ..不,我不打算垃圾网站..
这是我的代码
<?php
set_time_limit(9999999999999999);
require_once './simple_html_dom.php';
$GLOBALS['BASE_URL'] = "http://data.mysite.com";
$GLOBALS['cookieJar'] = "cookieTemp.txt";
function runCommand()
{
$csrf_token = getCSRFVal();
$payload = array(
"form_id" => "1",
"vfb-6[0]" => "Other",
"vfb-9" => "yes",
"vfb-10" => "yes",
"vfb-11" => "yes",
"vfb-12" => "options",
"vfb-14" => "test",
"vfb-15" => "test",
"vfb-16" => "447796272707",
"_wp_http_referer" => "/",
"_vfb-csrf-token" => $csrf_token,
);
$contentLength = strlen(http_build_query($payload));
$request_header = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding: gzip,deflate,sdch',
'Accept-Language: en-US,en;q=0.8,fil;q=0.6,th;q=0.4,it;q=0.2,es;q=0.2',
'Cache-Control: max-age=0',
'Connection: keep-alive',
'Host:data.mysite.com',
'Origin:http://data.mysite.com',
'Referer:http://data.mysite.com/',
'User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36',
'Content-Length:'.$contentLength,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$GLOBALS['BASE_URL']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER , $request_header);
curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookieJar']);
curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookieJar']);
$cur_res = curl_exec($ch);
echo $cur_res;
print_r(curl_getinfo($ch));
curl_close($ch);
}
function getCSRFVal()
{
$request_header = array(
'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language:en-US,en;q=0.8,fil;q=0.6,th;q=0.4,it;q=0.2,es;q=0.2',
'User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$GLOBALS['BASE_URL']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER , $request_header);
curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookieJar']);
curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookieJar']);
$page = curl_exec($ch);
$html_object = str_get_html($page);
curl_close($ch);
$tempCsrfToken = "";
if (@$html_object->find("input[name='_vfb-csrf-token']",0)->value) {
$tempCsrfToken = $html_object->find("input[name='_vfb-csrf-token']",0)->value;
}else{
echo "Cant get new csrf token";
die();
}
return $tempCsrfToken;
}
runCommand();
?>