curl specific ip

function curl($url, $params=array())
{
    $ch = curl_init('');
   
    $opts[CURLOPT_CONNECTTIMEOUT] = 10;
    $opts[CURLOPT_RETURNTRANSFER] = true;
    $opts[CURLOPT_TIMEOUT] = 3000;
    $opts[CURLOPT_CUSTOMREQUEST] = "POST";
    $opts[CURLOPT_SSL_VERIFYPEER ] = false;  
    $opts[CURLOPT_SSL_VERIFYHOST ] = false; // Ignore cert errors?
    $opts[CURLOPT_FRESH_CONNECT]  = TRUE;
    if($params)
    {
        $opts[CURLOPT_POSTFIELDS] = $params;
    }
    //$header = array("Cache-Control: no-cache",'Host: core-auth.trueid.net');
    $header = array('Host: core-auth.trueid.net');
    $opts[CURLOPT_URL] = $url;
    $opts[CURLOPT_HTTPHEADER] = $header;
   
   
    curl_setopt_array($ch, $opts);
    $result = curl_exec($ch);
    if($result === false)
    {
        $msgError = "Can't access web service. (".$url.")";
        curl_close($ch);
        throw new Exception($msgError, 100);
    }

    curl_close($ch);
    return $result;
}
$url = "https://203.144.214.43/";
echo curl($url);

ถ้าใน command line ก็คำสั่งนี้

curl --insecure https://xxx.xxx.xxx.xxx -H Host:subdomain.xxx.com

Related posts:

This entry was posted in php. Bookmark the permalink.