Curl命令,-H选项和Square API

时间:2014-09-18 01:34:39

标签: ios curl terminal nsurl square

我正在使用Square Connect API开发iOS应用。我需要连接以下命令:

curl -H "Authorization: Bearer ACCESS_KEY"
https://connect.squareup.com/v1/me/payments

iOS的相当于什么?

1 个答案:

答案 0 :(得分:1)

我终于明白了。在此发布此内容供其他人使用以供参考。

NSString *pswd = @"XXXXXXXXX";

NSURL *url = [NSURL URLWithString:@"https://connect.squareup.com/v1/me/payments"];
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];

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