()) { /-6ren">
gpt4 book ai didi

swift - Marvel API 409 响应, "You must provide a user key"

转载 作者:行者123 更新时间:2023-11-28 05:50:25 27 4
gpt4 key购买 nike

想知道是否有人可以帮助我:

    private static func getURLRequestData(completion: @escaping (Data?) -> ()) {

// Gets the raw JSON Data

let session = URLSession(configuration: .default)
guard let url = URL(string: urlString) else { return }
var urlRequest = URLRequest(url: url)

let headers = [
"ts" : ts,
"apikey" : apiKey,
"hash" : hash,
"limit" : limit,
"orderBy" : orderedBy
]

urlRequest.allHTTPHeaderFields = headers

let task = session.dataTask(with: urlRequest) { (data, response, error) in

if error != nil {
print(#line, error!.localizedDescription)
}

print(response)
completion(data)
}
task.resume()
}

如您所见,我使用我的 API key 正确设置了 header ,但出于某种原因,我收到了 409 返回,这是缺少“用户 key ”。

有没有人遇到过这样的事情。就其值(value)而言,完全相同的请求正在 Paw 中运行

最佳答案

您必须根据文档提供信息 link documentation here

示例:

var publickey = 'you-public-key';
var privatekey = 'you-private-key';
var ts = new Date().getTime();
var stringToHash = ts + privatekey + publickey;
var hash = md5(stringToHash);
var baseUrl = 'https://gateway.marvel.com:443/v1/public/characters';
var limit = 20;
var url = baseUrl + '?limit=' + limit + '&ts=' + ts + '&apikey=' + publickey + '&hash=' + hash;

关于swift - Marvel API 409 响应, "You must provide a user key",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53177335/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com