简体   繁体   中英

Google Docs Form Formkey in 2013 Custom Google Form

Hello I'm trying to develop a CURL PHP to send my Google Form through PHP first and then redirect to a landing page. However my issue lies within the old Google Formkey response.

Before you could view the form source and it would have a formkey ID number that you could easily insert into a PHP script.

Here is my script sample:

//Google Form Key
$formkey = "WHERE IS THE FORMKEY";

$thankyou = "http://www.eksenaevents.com/submission-successful/";

//Change this URL to your google form address
$googleformURL = "https://docs.google.com/forms/d/1pCIHFvau8KuR_J1gSAx2weGcdRGjNH0MERdeinbWd-  0/viewform";

//----------------Send Form Fields to Google--------------------
//Loops through the form fields and creates a query string to submit to google
foreach ($_POST as $var => $value) {

if ($var != "ignore") {
$postdata=$postdata . htmlentities(str_replace("_", "." , $var)) . "=" . $value . "&";
}
 } 

//remove the extra comma
$postdata=substr($postdata,0,-1); 

//Submit the form fields to google
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$googleformURL);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;   rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$data = curl_exec ($ch);
curl_close($ch); 
//echo $data;

//Redirect to your thank you page
header( "Location: $thankyou" ) ;

?>

I know the guy probably won't see this but for other people, your form key is. . 1pCIHFvau8KuR_J1gSAx2weGcdRGjNH0MERdeinbWd

also your google form url should be like this

https://docs.google.com/yourdomainwhatev/spreadsheet/formResponse?formkey=insert your form key here#gid=0

if you open your form, just copy the web address and rip out the form key

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM