【发布时间】:2014-11-10 01:22:18
【问题描述】:
我想从 Make your first call in paypal 获取访问令牌
我正在将 Curl 转换为目标 c
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" \
-d "grant_type=client_credentials"
我的 Objective c 代码是这样的.....
ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"https://api.sandbox.paypal.com/v1/oauth2/token"]];
request.tag = 1010;
[request setRequestMethod:@"POST"];
[request setUsername:@"kclientID"];
[request setPassword:@"kSecrestID"];
[request addRequestHeader:@"Accept" value:@"application/json"];
[request addRequestHeader:@"Accept-Language" value:@"en_US"];
NSMutableData *data1 = [[NSMutableData alloc] initWithData:[[NSString stringWithFormat:@"grant_type=client_credentials"] dataUsingEncoding:NSUTF8StringEncoding]];
[request setPostLength:[data1 length]];
[request setPostBody:data1];
[request setDelegate:self];
[request setDidFinishSelector:@selector(uploadFinishedLocation:)];
[request setDidFailSelector:@selector(uploadFailLocation:)];
[request startAsynchronous];
有人知道这些代码有什么问题吗?
【问题讨论】:
标签: ios objective-c iphone cocoa-touch paypal