PHP variables in CURL URL
P粉762730205
P粉762730205 2024-02-25 21:03:22
0
1
406

I've searched many previous posts here but nothing seems to solve my problem. In short, I want to include a PHP variable in the code below. The code below works fine because it is hardcoded, but when I replace the word MAYIAHH with the variable $hid (declared), I get an error.

I've tried CURLOPT_POSTFIELDS and various methods but nothing seems to help. Any ideas?

function send_request($xml)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 
        'https://rest.reserve-online.net/availability?properties=MAYIAHH');
    curl_setopt($ch, CURLOPT_USERPWD, "uname:pass");
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    curl_close($ch);
    
    return $result;
}

P粉762730205
P粉762730205

reply all(1)
P粉771233336

Have you tried concatenating the url string?

$hid = 'MAYIAHH';
$url = 'https://rest.reserve-online.net/availability?properties='.$hid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "uname:pass");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template