我正在制作将自动填写Google Forms文档的PHP脚本。我正在使用Curl.However,这个脚本的工作正确性存在问题
$text="forTestOnly";
if( $curl = curl_init() ){
curl_setopt($curl,CURLOPT_URL,'https://docs.google.com/forms/d/1bJXxSXzIkm7NtDCZXE4J3VF5UugVm4B_qTFuGFp1bKE/viewform');
curl_setopt($curl, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate');
curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($curl,CURLOPT_HEADER,true);
if( $html = curl_exec($curl) ){
curl_setopt($curl,CURLOPT_URL,'https://docs.google.com/forms/d/1bJXxSXzIkm7NtDCZXE4J3VF5UugVm4B_qTFuGFp1bKE/viewform');
curl_setopt($curl,CURLOPT_POST,TRUE);
curl_setopt($curl,CURLOPT_POSTFIELDS,"entry.867207060=$text&submit=ok");
$out = curl_exec($curl);
echo $out;
}
curl_close($curl);
}
它出现了这样的错误:" HTTP / 1.1 405方法不允许" 。有什么问题?
关于
修改
问题不在 Curl (POST)的设置中,但我提供的网址不正确。
答案 0 :(得分:0)
似乎Google可能已禁止使用Google表单的POST方法,可能是为了预防自动请求。
见
POST Request not supported by Google Server
有关您为什么要提供错误消息的一般说明,或者更好的
cURL not fetching the expected POST response - error 405
寻求可能的解决方案 - 请参阅建议的高级答案
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( array(...) ));
方法,可能允许或不允许您绕过Google的反自动化措施。