首页 > [已解决]curl-php代码是还需要添加什么,已经设置digest,是不是哪里不对?

[已解决]curl-php代码是还需要添加什么,已经设置digest,是不是哪里不对?

<?php

function fetch($url){

    $ch = curl_init();

    curl_setopt ($ch, CURLOPT_URL, $url);

     curl_setopt($ch, CURLOPT_NOBODY, FALSE); //表示需要response body

    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
    curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_DIGEST);

    curl_setopt($ch, CURLOPT_GET, 1);

    $data = curl_exec($ch);

    curl_close($ch);

    return $data;

}
$url = "";
$url = "http://192.168.1.173:8080/cas/casrs/hostpool/all";

$yy = fetch($url);
echo $yy;
echo xx;

我将这个文件放到apache下面,然后访问这个文件,我想实现的命令是
curl -v --digest http://192.168.1.173:8080/cas...

我已经设置digest,curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_DIGEST);
还应该设置什么,谢谢

【热门文章】
【热门文章】