加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – Postman生成的代码中的邮递员令牌头属性是什么?

发布时间:2021-07-06 05:25:37 所属栏目:大数据 来源: https://www.jb51.cc
导读:我一直在使用邮递员来探索REST界面.使用Postman的代码生成功能时,无论我选择哪种编程语言,Postman都会在标题中添加postman-token属性.为什么会这样? 参见例如PHP Curl: ?PHP$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL = "https://my

我一直在使用邮递员来探索REST界面.使用Postman的代码生成功能时,无论我选择哪种编程语言,Postman都会在标题中添加postman-token属性.为什么会这样?

参见例如PHP Curl:

<?PHP

$curl = curl_init();

curl_setopt_array($curl, array(CURLOPT_URL => "https://myURL.com,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
  "authorization: Basic abcdefghijklmnop",
  "cache-control: no-cache",
  "postman-token: wt53gwg-e9bb-645d-g53d-e42f8765aut0"
  ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

解决方法:

This is primarily used to bypass a bug in Chrome. If an XMLHttpRequest is pending and another request is sent with the same parameters then Chrome returns the same response for both of them. Sending a random token avoids this issue. This can also help you distinguish between request on the server side.

请参阅docs / settings postman.

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读