2013-02-06 60 views
1

你好,我試圖開發捲曲PHP通過PHP先把我的谷歌表格,然後重定向到着陸頁。不過,我的問題在於舊的Google Formkey響應。谷歌文檔形式Formkey在2013年穀歌自定義表單

之前,你可以查看窗體源,它會有一個formkey ID號,你可以很容易地插入到PHP腳本。

這裏是我的腳本樣本:

//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") ; 

?> 
+0

你會在哪裏使用'$ formkey'變量?我看不到你在任何地方使用它。 –

回答