I'm working on something but I do not understand what is happening. I tried different things. I'm sending a get request to website but it's not working, the curl always returns false. But if I put the url to the browser and check it, I got some response. here's the url
"https://cleanlead.dlg.co.uk/?circuit=public&fuseaction=lead&Campid=599&Suppid=571&Surveyid=5&Title=Mr&Forename=Adrian&Surname=Reut&Address1=8 Church Road Middlesex&Finance_Insurance_PMI_CurrentlyHave=Yes&Postcode=UB3 2LH&Finance_PMI_ThruCompany=No&TelephoneORMobile=2087976760&Age_Band=30-39"
Here' my curl code
$ch = curl_init();
//var_dump($url.$postData);
curl_setopt($ch,CURLOPT_URL,urlencode("https://cleanlead.dlg.co.uk/?circuit=public&fuseaction=lead&Campid=599&Suppid=571&Surveyid=5&Title=Mr&Forename=Adrian&Surname=Reut&Address1=8 Church Road Middlesex&Finance_Insurance_PMI_CurrentlyHave=Yes&Postcode=UB3 2LH&Finance_PMI_ThruCompany=No&TelephoneORMobile=2087976760&Age_Band=30-39"));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$output=curl_exec($ch);
curl_close($ch);
var_dump($output);
You need to urlencode()
only the value parts of your query string, fields Postcode
and Address1
in this case.
<?php
$ch = curl_init();
//var_dump($url.$postData);
$requestUrl = "https://cleanlead.dlg.co.uk/?";
$requestUrl .= "circuit=public&fuseaction=lead&Campid=599&Suppid=571&Surveyid=5&Title=Mr&Forename=Adrian&Surname=Reut";
$requestUrl .= "&Address1=" . urlencode("8 Church Road Middlesex");
$requestUrl .= "&Finance_Insurance_PMI_CurrentlyHave=Yes";
$requestUrl .= "&Postcode=" . urlencode("UB3 2LH");
$requestUrl .= "&Finance_PMI_ThruCompany=No&TelephoneORMobile=2087976760&Age_Band=30-39";
curl_setopt($ch,CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$output=curl_exec($ch);
if (curl_error($ch)) {
var_dump();
}
curl_close($ch);
var_dump($output);
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.