Submit data to Google Spreadsheet Form from Objective-C

前端 未结 5 1826
无人及你
无人及你 2020-12-07 02:42

Is there a library, blog post, etc. that can be used to submit data to a Google Spreadsheet using Forms ?

I could probably write up the Http POST stuff but I was won

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 02:54

    For it to work with restrict to certain email addresses and to send the Username (the email address) automatically then you need to submit the hidden fields in the form

    fbzx fvv draftResponse pageHistory token (this is not the access token, it is a hidden input in the form called "token", use something like

    NSString *authValue = [NSString stringWithFormat:@"Bearer %@", yourAccessTokenGottenFromGTMOAuth];
    [request setValue:authValue forHTTPHeaderField:@"Authorization"]; 
    

    to do the access token you need for it to work when restricted to certain emails

    Use cocoapods

    pod 'GTMOAuth2', '~> 1.1.2'
    pod 'GTMSessionFetcher', '~> 1.1'
    

    Do the auth as the OSX example shows (included in the cocoapod for GTMOAuth2)

    You must first HTTP GET the form html and parse it (using NSScanner is a good way to parse it) for the hidden input fields such as fbzx and draftResponse and token.

    Then when you have that and your access token gotten from google auth you do a post that looks something like:

    draftResponse=stringGottenFromHTMLGETAndParse&entry.someNumber=someValue&fbzx=stringGottenFromHTMLGETAndParse2&fvv=stringGottenFromHTMLGETAndParse3&pageHistory=stringGottenFromHTMLGETAndParse4&token=stringGottenFromHTMLGETAndParse5

    I needed to do the GTMOAuth2 for the HTTP Post to work when restricting submitters to certain email addresses in the form but didn't need the hidden inputs such as draftResponse and token.

    I needed to add the hidden inputs such as fbzx for the HTTP POST to work when I had the option enabled on the form to automatically submit the users email with the form.

提交回复
热议问题