NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Can anyone advise on Curl?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 02-05-2006, 03:26 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
sdtrader's Avatar
Join Date: Aug 2005
Location: Canada
Posts: 591
sdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of light
 



Can anyone advise on Curl?


I've managed to figure out how to convert an fopen command in the past but this one stumps me.If anyone can assist in coming up with a usable curl command it would be greatly appreciated.It comes from cp_email script.
`````````````````````````````````````````````````` `````````
$filepointer = fopen($url,"r");

if($filepointer){

while(!feof($filepointer)){

$buffer = fgets($filepointer, 4096);

$file .= $buffer;

}

fclose($filepointer);

} else {

die
sdtrader is offline  
Old 02-05-2006, 04:16 AM   #2 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Pulled this from one of my old scripts, maybe you can hack at it...
PHP Code:
<?php

$curl_session 
curl_init();
curl_setopt($curl_sessionCURLOPT_URL"http://www.somedomain.com/index.php?");
curl_setopt($curl_sessionCURLOPT_POST1);
curl_setopt($curl_sessionCURLOPT_POSTFIELDS"this=".$that);
????: NamePros.com http://www.namepros.com/programming/164645-can-anyone-advise-on-curl.html
curl_setopt($curl_sessionCURLOPT_HEADER0);
curl_setopt($curl_sessionCURLOPT_RETURNTRANSFER1);
$content curl_exec($curl_session);

//Do whatever you want with $content here..

curl_close($curl_session);

?>
Eric is offline  
Old 02-05-2006, 08:03 AM   #3 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



SecondVersion has the basics above. Basically what you have to do is initialize the curl sesison, set the options, then execute the command. The most difficult portion is setting the options.

PHP Code:
$url 'http://<URL HERE>';
$ch curl_init($url);
????: NamePros.com http://www.namepros.com/showthread.php?t=164645
. . . 
Set options . . . 
$result curl_exec($ch); 
There are loads of options. Depending on what you want to do, you need to either set or not set the RETURN_TRANSFER option.

If you want to DISPLAY the results, then don't set it (or set it to 0). If you want to CAPTURE the data for processing and store it in a variable, you MUST set the "RETURNTRANSFER" variable to 1.

If you want to POST data to a URL (i.e. like you were posting info from a form), then you need to build the query string in a loop- something like:

PHP Code:
$postFields='a=b&c=d&e=f&g=h'
You then set the post fields withe CURLOPT_POSTFIELDS option.

Here is one example I had that interacts with Authorize.net:

PHP Code:

foreach( $authnet_values as $key => $value $fields .= "$key=" urlencode$value ) . "&";

$ch curl_init("https://certification.authorize.net/gateway/transact.dll");
curl_setopt($chCURLOPT_HEADER0); // set to 0 to eliminate header info from response
curl_setopt($chCURLOPT_RETURNTRANSFER1); // Returns response data instead of TRUE(1)
curl_setopt($chCURLOPT_POSTFIELDSrtrim$fields"& " )); // use HTTP POST to send form data
????: NamePros.com http://www.namepros.com/showthread.php?t=164645
$resp curl_exec($ch); //execute post and get results
curl_close ($ch); 
The you can do whatever you need to with the $resp.

Good luck!

-Bob
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Old 02-05-2006, 12:28 PM THREAD STARTER               #4 (permalink)
NamePros Regular
 
sdtrader's Avatar
Join Date: Aug 2005
Location: Canada
Posts: 591
sdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of lightsdtrader is a glorious beacon of light
 



Thanks guys I will let you know how it goes.
sdtrader is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Php Module help (cUrl) / Alternative squirrelbacon Programming 2 12-01-2005 09:15 AM
Need help with curl install will pay NP dreaminginspiration Programming 5 11-19-2005 02:00 AM
Newbie looking for advise. napalm747 Website Development 8 06-11-2005 08:31 AM
Need Advise! patches Domain Name Discussion 1 04-22-2005 11:35 AM
Registrar Question.. please advise Wanda Domain Name Discussion 4 09-15-2004 05:20 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:20 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger