Welcome to WebmasterWorld Guest from 54.146.180.94

Forum Moderators: coopster & jatar k

curl connection and pass headers

curl connection using ip

   
4:11 pm on Jul 17, 2009 (gmt 0)

5+ Year Member



Hello,

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);
?>

5:28 pm on Jul 17, 2009 (gmt 0)

10+ Year Member




$return = curl_exec($process);
if($return === false)
{
die ('Curl error: ' . curl_error($process));
}
7:12 pm on Jul 17, 2009 (gmt 0)

5+ Year Member



Nomik what does this do for me?
7:27 pm on Jul 17, 2009 (gmt 0)

5+ Year Member



can i call a curl connection with an ip?
4:35 am on Jul 19, 2009 (gmt 0)

5+ Year Member



As far as i know there is no difference between using CURL to access a server by domain name or IP address. Have you tried:

$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.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month