从Objective-C向Google Spreadsheet Form提交数据 [英] Submit data to Google Spreadsheet Form from Objective-C

查看:97
本文介绍了从Objective-C向Google Spreadsheet Form提交数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可用于使用表单提交数据到Google Spreadsheet的图书馆,博客帖子等?



我可能会写出Http POST东西,但我想知道是否有人已经这样做了,我可以利用。



这个问题就像是iOS的等同于问题。

解决方案

基于@Saad Farooq的回答,我实际上尝试编写代码

   - (void) viewDidLoad 
{
[super viewDidLoad];

//如果有连接正在取消它。
[self.connection cancel];

//初始化新的可变数据
NSMutableData * data = [[NSMutableData alloc] init];
self.receivedData = data;

//初始化要获取的网址。
NSURL * url = [NSURL URLWithString:@https://docs.google.com/forms/d/1yffvViDKq7BHALtC7Om-ceFLWT5hb_cM9sBqndHG3aU/formResponse];

//从url初始化请求
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:[url standardizedURL]];

//设置http方法
[request setHTTPMethod:@POST];
//初始化发布数据
NSString * postData = @entry.154268020 = iOS& entry.940479455 = vajhcsd& entry.247556683 = BJKSVDB;
//设置请求内容类型我们必须设置这个值。

[request setValue:@application / x-www-form-urlencoded; charset = utf-8forHTTPHeaderField:@Content-Type];

//设置请求数据
[request setHTTPBody:[postData dataUsingEncoding:NSUTF8StringEncoding]];

//从请求初始化一个连接
NSURLConnection * connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
self.connection =连接;

//开始连接
[connection start];





$ b}

,它确实有效。您需要从@ Saad的教程这里。顺便说一句,我是谁试图发布以前的链接。非常感谢通知他的SO员工。

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 wondering if someone had done so already that I can utilize.

This question is like the iOS equivalent of this question for Android.

解决方案

based on @Saad Farooq's answer, I actually tried writing the code

- (void)viewDidLoad
{
    [super viewDidLoad];

    //if there is a connection going on just cancel it.
    [self.connection cancel];

    //initialize new mutable data
    NSMutableData *data = [[NSMutableData alloc] init];
    self.receivedData = data;

    //initialize url that is going to be fetched.
    NSURL *url = [NSURL URLWithString:@"https://docs.google.com/forms/d/1yffvViDKq7BHALtC7Om-ceFLWT5hb_cM9sBqndHG3aU/formResponse"];

    //initialize a request from url
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[url standardizedURL]];

    //set http method
    [request setHTTPMethod:@"POST"];
    //initialize a post data
    NSString *postData = @"entry.154268020=iOS&entry.940479455=vajhcsd&entry.247556683=BJKSVDB";
    //set request content type we MUST set this value.

    [request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];

    //set post data of request
    [request setHTTPBody:[postData dataUsingEncoding:NSUTF8StringEncoding]];

    //initialize a connection from request
    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    self.connection = connection;

    //start the connection
    [connection start];






}

and it actually works. You need to extract the URLs etc from @Saad's tutorial here. BTW, I was the one who tried posting that the previous links. A big thank you to the SO staff who informed him.

这篇关于从Objective-C向Google Spreadsheet Form提交数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆