所以我在使用 Marvel API 时遇到了这个错误,而且我在任何地方都找不到它的踪迹。
`409 Conflict` response: {"code":"MissingParameter","message":"You must provide a user key."}
我已经查看了 API 文档,但找不到任何关于用户 key 的信息。
这是我的代码;我将 Laravel 与 Guzzle 一起使用。
$res = $client->request('GET', 'http://gateway.marvel.com:80/v1/public/comics', [
'apikey' => $apikey,
'ts' => $now,
'hash' => md5($now . $privateKey . $apikey),
]);
如有任何帮助,我们将不胜感激。
最佳答案
尝试使用 http_build_query :
$query = http_build_query([
'apikey' => $apikey,
'ts' => $now,
'hash' => md5($now . $privateKey . $apikey)
]);
$url = 'http://gateway.marvel.com:80/v1/public/comics?' . $query;
$res = $client->request('GET', $url);
更新
看起来你只需要设置 query请求中的选项。
$res = $client->request('GET', 'http://gateway.marvel.com:80/v1/public/comics', [
'query' => [
'apikey' => $apikey,
'ts' => $now,
'hash' => md5($now . $privateKey . $apikey)
]
]);
关于laravel - `409 Conflict` 响应 : { "code": "MissingParameter", "message":"You must provide a user key."},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51804643/