【发布时间】:2019-03-08 23:05:18
【问题描述】:
要对 API 调用进行身份验证,您必须首先生成会话以获取令牌。然后您必须发送会话令牌作为 X-Auth-Token 标头的值来验证 API 调用。
要创建会话,您首先需要手动生成 API 密钥。这是可以在 API 访问页面中生成的键/值对。当您单击 Generate New API Key 时,将显示一个带有 API Key Value 的弹出窗口,在 Active Keys 表中您可以找到 API Key ID。然后通过基本身份验证在 POST 调用中将其发送到会话路由。
我已经关注了 deepcrawl 的这个 Api 文档,但是我做错了什么?
我有X-Auth-Token 和API KEY ID 我应该把这个放在哪里?
$deephead = "X-Auth-Token: asdjasiojqoieuqiouwqpofoqwojeq";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.deepcrawl.com/sessions");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $deephead);
// Get the response
$response = curl_exec($ch);
// Close cURL connection
curl_close($ch);
// Decode the response (Transform it to an Array)
$result = json_decode($response);
//debug the response
dd($result);
我什至无法到达CURLOPT_GET,因为在我的post 我只得到空值。任何想法/想法我该如何解决这个问题。先感谢您。
【问题讨论】: