Skip to main content
Participant
September 19, 2009
Answered

Using CFHTTP to submit a form directly to a google docs form

  • September 19, 2009
  • 1 reply
  • 1697 views

Ok so here is some background

Google has a service where you can create forms using google docs and embed them into your webpage, Results are automatically stored in a google spreadsheet upon submission.

I want to use my own form to submit to to the google form processing page which I can get to work however the default generic google hosted thank you page appears upon submissing.

I know you can use cfhttp to submit a form from a coldfusion server so I was thinking that I could simply pass my form variables to a action page that resubmitted them via cfhttp and thus bypass the thank you page altogether

however when I try this it does not work and the results do not show up in the google spreadsheet. I figured that mabye the google processing page could tell that it was not submitted from a browser so I tired adding a useragent string but still no luck.

Here is the code I was trying to use

<cfhttp method="POST" url="https://spreadsheets.google.com/formResponse?key=tlo4FjygqMuUGmvuOb2_Gjw" redirect="yes" useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)">
 
     <cfhttpparam type="Formfield" name="entry.0.single" value="testValue1" >
     <cfhttpparam type="Formfield" name="entry.1.single" value="testValue2" >
     
</cfhttp>

And the online spread sheet can be viewed here


http://spreadsheets.google.com/pub?key=tlo4FjygqMuUGmvuOb2_Gjw&single=true&gid=0 &output=html

Does anyone know why this is not working?

To recap I am able to use the following form on my own comptuer to directly submit to the processing page and this works

<form action="https://spreadsheets.google.com/formResponse?key=tlo4FjygqMuUGmvuOb2_Gjw" method="POST">
<input type="text" name="entry.0.single" value="" >
<input type="text" name="entry.1.single" value="">
<input type="submit" name="submit" value="Submit">
</form>

Any help would be greatly appreciated

    This topic has been closed for replies.
    Correct answer BKBK

    What if you also include the submit field as cfhttpparam?

    1 reply

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    September 19, 2009

    What if you also include the submit field as cfhttpparam?

    Participant
    September 19, 2009

    YES!!!!!!!!!!!!!!!!!!!!!! This did it final code is as follows thanks for you help

    <cfhttp method="POST" url="https://spreadsheets.google.com/formResponse?key=tlo4FjygqMuUGmvuOb2_Gjw" useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)">
     
         <cfhttpparam type="Formfield" name="entry.0.single" value="final test">
         <cfhttpparam type="Formfield" name="entry.1.single" value="final test">
          <cfhttpparam type="Formfield" name="submit" value="Submit">

    </cfhttp>

    Man this is great! and has eliminated half my database requirements! now only if you could pull the results back out!

    BKBK
    Community Expert
    Community Expert
    September 19, 2009

    A point of etiquette. Yes-but reactions can give the impression your question hasn't been answered, or that you're ungrateful. Please, first kindly acknowledge what helps.

    It's nice, but not enough to thank me. Say what it is that you thank me for. That is what those who come here looking for an answer to a similar question would want to know. Only then, should you proceed to the next question.