Welcome to WebmasterWorld Guest from 54.242.224.250

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

curl connection and pass headers

curl connection using ip

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

New User

5+ Year Member

joined:Feb 9, 2009
posts:16
votes: 0


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 July 17, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 22, 2005
posts:185
votes: 0



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

New User

5+ Year Member

joined:Feb 9, 2009
posts:16
votes: 0


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

New User

5+ Year Member

joined:Feb 9, 2009
posts:16
votes: 0


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

Junior Member

5+ Year Member

joined:Feb 13, 2008
posts:130
votes: 0


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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members