homepage Welcome to WebmasterWorld Guest from 184.73.52.98
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
curl connection and pass headers
curl connection using ip
redfoxhound




msg:3954462
 4:11 pm on Jul 17, 2009 (gmt 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);
?>

 

NomikOS




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


$return = curl_exec($process);
if($return === false)
{
die ('Curl error: ' . curl_error($process));
}

redfoxhound




msg:3954566
 7:12 pm on Jul 17, 2009 (gmt 0)

Nomik what does this do for me?

redfoxhound




msg:3954573
 7:27 pm on Jul 17, 2009 (gmt 0)

can i call a curl connection with an ip?

idfer




msg:3955212
 4:35 am on Jul 19, 2009 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved