iOS POST 到 Google 表单(电子表格)

标签 ios iphone objective-c http google-docs

我正在尝试设置一个非常简单的应用程序,它从输入字段中获取数字,然后使用 NSMutableURLRequest 使用 Google 表单中的操作 URL 将 POSTS 发送到 Google 电子表格.

到目前为止,我有一个简单的文本框和按钮,以及这段代码。我使用的字段名称是: name="entry.931001663"

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *inputField;
- (IBAction)submit:(id)sender;

@end

@implementation ViewController

- (void)viewDidLoad
{
 [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
} 

- (IBAction)submit:(id)sender {

NSString *bodyData = self.inputField.text;
NSLog(@"Input = %@", bodyData);
NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://docs.google.com/forms/d/1rGpFfI2ebyn_SbuDVVUg7Q4yuvKzd3RRXb0vRxeIDxc/formResponse"]];
[postRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[postRequest setHTTPMethod:@"POST"];
[postRequest setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:strlen([bodyData UTF8String])]];



}
@end

最佳答案

我不确定这个错误,但是Google's Sample Code可以帮你。您还可以使用GData Objective C Client使用它。

关于iOS POST 到 Google 表单(电子表格),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20281937/

相关文章:

android - Firebase:获取当前时间而不写入数据库(IOS 和 ANDROID)

ios - 无法点击 SwiftUI 网格图像来显示 DetailView

iphone - 使用 xCode 4.3.3 使用未声明的标识符 'NSLineBreakByWordWrapping'

iphone - setIndentationLevel 不适用于 cell.ContentView subview

objective-c - 在 View Controller 的实现和头文件中出现“@interface ViewController”的原因

iphone - 使用模态视图 Controller 添加到 TableView

iphone - 裁剪图像后,保存的图像质量降低

ios - (Objective-C) pageView中的viewController在来回分页时得到 "stuck"

objective-c - 为什么 "conformsToProtocol"不检查 "required"方法实现?

iphone - 我遇到了一个关于 float 的麻烦。帮帮我