Php 使用CURL将表单提交到google表单

Php 使用CURL将表单提交到google表单,php,curl,Php,Curl,我写了下面的代码,但它的内部错误出现提交。我不知道出了什么问题 <?php //extract data from the post //extract($_GET) ; //set POST variables //The form https://spreadsheets.google.com/viewform?authkey=CJPbtZkI&hl=en&formkey=dEd5UFhRQ1ZfNzcwU1UwOVhIbF92cGc6MQ&ifq $url

我写了下面的代码,但它的内部错误出现提交。我不知道出了什么问题

<?php

//extract data from the post
//extract($_GET) ;
//set POST variables

//The form https://spreadsheets.google.com/viewform?authkey=CJPbtZkI&hl=en&formkey=dEd5UFhRQ1ZfNzcwU1UwOVhIbF92cGc6MQ&ifq
$url = 'https://spreadsheets.google.com/formResponse?authkey=CJPbtZkI&amp;hl=en&amp;formkey=dEd5UFhRQ1ZfNzcwU1UwOVhIbF92cGc6MQ&amp;ifq' ;
$fields = array(
'pageNumber'=>urlencode("0" ) ,
'backupCache'=>urlencode("") ,
'submit'=>urlencode("Submit"),
'entry.0.single'=>urlencode("") ,
'entry.1.single'=>urlencode("") ,
'entry.2.single'=>urlencode("") ,
'entry.3.single'=>urlencode("") ,
'entry.4.single'=>urlencode("") ,
'entry.5.single'=>urlencode("") ,
'entry.6.single'=>urlencode("") ,
'entry.7.single'=>urlencode("") ,
'entry.8.single'=>urlencode("") ,
'entry.9.single'=>urlencode("") ,
'entry.10.single'=>urlencode("") ,
'entry.11.single'=>urlencode(""),
'entry.12.single'=>urlencode("")
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&' ; }
rtrim($fields_string ,'&') ;
//open connection
$ch = curl_init() ; 
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL,$url) ;
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml','Accept-Charset: UTF-8')); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string) ;
//execute post
$result = curl_exec($ch) ;
print_r($fields_string);
//close connection
curl_close($ch) ;

?>

第一个明显的问题是,您尝试使用的URL是HTML编码的(例如,它有
&;
用于
&

请尝试添加以下内容:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

挑剔的点,但是您的
$field_strings
变量仍然有尾随的符号AND。您需要执行以下操作:

$fields_string = rtrim($fields_string ,'&') ;

嗨,我也在做同样的事情,但我的仍然不起作用,如果可以的话,请你帮忙好吗?我可以把代码发送到哪里?