どうしても解決しないので、ご質問させていただきます。
http://techbureau-api-document.readthedocs.io/ja/latest/trade/1_common.html#id2
こちらのAPIを試しているのですが、どうしてもい以下の(signature mismatch)のエラーが帰ってきてしまいます。原因がわからないのですが、何がおかしいのでしょうか?
{
error = signature mismatch";
success = 0;
}
----以下、実際のコードです。-------------------------------
-
(void)httpRequest {
NSError *error;
double unixtime = [[NSDate date] timeIntervalSince1970];NSDictionary *parameters = @{@"nonce":[NSString stringWithFormat:@"%f",unixtime], @"method":@"get_info"};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSString *url = @"https://api.zaif.jp/tapi";
NSMutableURLRequest *req = [[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:url parameters:nil error:nil];
[req setValue:@"xxxxxxxxxxxxxxxxxxx" forHTTPHeaderField:@"key"];
[req setValue:[self sha512:jsonString withSalt:@"xxxxxxxxxxxxxxxxxx"] forHTTPHeaderField:@"sign"];
// [req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
// [req setValue:@"application/json" forHTTPHeaderField:@"Accept"];
// [req setHTTPBody:[[self sha512:jsonString] dataUsingEncoding:NSUTF8StringEncoding]];
[[manager dataTaskWithRequest:req completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (!error) {
NSLog(@"Reply JSON: %@", responseObject);
if ([responseObject isKindOfClass:[NSDictionary class]]) {
//blah blah
}
} else {
NSLog(@"Error: %@, %@, %@", error, response, responseObject); } }] resume];
}
宜しくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/28 15:41
2017/10/28 15:49