我有一段代码试图调用 Cloudstack REST API:
function file_get_header($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
$datas = curl_exec($ch);
curl_close($ch);
return $datas;
}
$url = "http://10.151.32.51:8080/client/api?" . $command . "&" . $signature . "&" . $response;
echo $test = file_get_header($url);
输出是这样的:
HTTP/1.1 200 OK 服务器:Apache-Coyote/1.1 Set-Cookie:JSESSIONID=74A5104C625549EB4F1E8690C9FC8FC1;Path=/client Content-Type: text/javascript;charset=UTF-8 Content-Length: 323 Date: Sun, 01 Jun 2014 20:08:36 GMT
我要做的是如何仅打印 JSESSIONID=74A5104C625549EB4F1E8690C9FC8FC1 并将其分配给变量?谢谢,