laravel - `409 Conflict` 响应 : { "code": "MissingParameter", "message":"You must provide a user key."}

标签 laravel rest api

所以我在使用 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/

相关文章:

php - 在 Laravel 中使用 request->all 保存所有记录记录

rest - 如何找到Cloud Firestore项目的数据库ID?

authentication - Laravel 5 db :seed the username and password, 但未在登录时进行身份验证

php - Laravel 4.2 多对多关系 : Can't read from pivot table

java - Spring 版本变更导致 RESTful 功能中断

rest - Elasticsearch:地理位置距离查询错误

Node.js 并行调用同一子休息服务并聚合响应

javascript - 创建一个简单的 google books api

php - 我可以在 Azure 逻辑应用程序中进行 SOAP API 调用吗

laravel - 如何删除第一行