iOS发布到Google表单(电子表格)

时间:2013-11-29 09:10:21

标签: ios iphone objective-c http google-docs

我正在尝试使用Google表单中的操作网址设置一个非常简单的应用程序,该应用程序从输入字段中获取一个数字,然后使用NSMutableURLRequest将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

1 个答案:

答案 0 :(得分:1)

我不确定错误,但Google's Sample Code可以帮助您。您也可以使用GData Objective C Client来使用它。