欢迎各位兄弟 发布技术文章
这里的技术是共享的
php 代码 curl 的 Authorization:Bearer
function _exec_command_in_computer_from_jamf($command_name, $token, $data)
{
$ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, "https://aaaa.bbbb.com:8443/JSSResource/computers/macaddress/${mac}");
if ($_GET['new']) {
curl_setopt($ch, CURLOPT_URL, "https://aaaa.bbbb-ict.com:8443/JSSResource/computercommands/command/{$command_name}");
} else {
curl_setopt($ch, CURLOPT_URL, "https://aaaa.bbbb-ict.com:8443/JSSResource/computercommands/command/{$command_name}");
}
$headers = array('Authorization:Bearer ' . $token, 'Content-Type: application/xml;charset=utf-8', 'Content-Length: ' . strlen($data), 'Accept' => 'application/xml');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // to resolve your current error
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
// curl_setopt($ch, CURLOPT_PUT, 1);//加上这行 好像有报错,
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
if (!empty($data_arr)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, drupal_json_encode($data_arr));
}
$response = curl_exec($ch);
if (curl_error($ch)) {
$response = curl_error($ch);
}
curl_close($ch);
return $response;
}
postman 使用 Authorization
或者
postman 使用 Headers