Forum Moderators: coopster
I am trying to build a curl connection but does not use a domain, instead it uses an ip.
Then I am trying to pass headers to the connection. I am having trouble doing it. Can anyone please see if I am in the right direction?
I made up the ip
<?php
$user_agent=$_SERVER['HTTP_USER_AGENT'];
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "197.114.117.30");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('GET /?adsource=adwords&campaign=105glacierbankcombusCardsVisaCheck&adgroup=cash%20advance%20credit%20card&keyword=keyword&query=keyword&creativeid=creative&traffictype=ifsearch:searchifcontent:content&sourcesite=placement&redir=http%3A%2F%2Fwww.domain.com%2FbusCardsCredit.cfm HTTP/1.1'));
$result=curl_exec($ch);
curl_close($ch);
?>
$ch=curl_init('http://197.114.117.30/?adsource=...');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$return = curl_exec($ch);
if($return === false) {
die ('Curl error: ' . curl_error($ch));
}
The if statement mentioned by NomikOS will print out any potential errors, it'll take out some of the guesswork if things don't work. Hope this helps.