How do I post to a Google script with cURL in PHP and return text?

前端 未结 2 1645
闹比i
闹比i 2021-01-15 20:16

I\'m trying to do the bare minimum, just to get it working.

Here is my Google Script:

function doPost(e) {
  return ContentService.createTextOutput(J         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-15 20:49

    You need to look at your HTTP Request header to see what is actually being posted.

    When trouble shooting I add these options:

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_TIMEOUT,10);
    curl_setopt($ch, CURLOPT_FAILONERROR,true);
    curl_setopt($ch, CURLOPT_ENCODING,"");
    
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    

    CURLINFO_HEADER_OUT will add "request_header" to curl_getinfo()

    You also want to look at these curl_getinfo() elements.

    • request_size
    • size_upload
    • upload_content_length
    • request_header

提交回复
热议问题