Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hello, I am relatively new to all the coding.

But I have a question regarding cURL and PHP. How do I execute a cURL
command in PHP?
I've read a few hours on the net about cURL, but I am having a hard
brain freeze due to all the complex stuff.

curl -u user:password


Re: cURL

Dennis J wrote:
Quoted text here. Click to load it

You can always use exec() to execute the command, but PHP has a whole
series of cURL functions and options which should do what you want.
Check them out first.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: cURL

El 10/02/2010 1:55, Dennis J escribió/wrote:
Quoted text here. Click to load it

In general, it's better the check the official manual first:

In "Function Reference-> Other Services" (yep, it's not very obvious)
you'll find there're builtin cURL functions in PHP, so you don't need to
use the command line tool:

Have a look at the example and elaborate on it.

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor satinado:

Re: cURL

Depending on the options you'll need, you can set the options as below
code (I required a security certificate on the host so my settings set
these options).

$url = " ";
$credentials = "user:pass"; // using : to split un/pw

// Initialize session and set URL.
$ch = curl_init();
// set up the connection
curl_setopt($ch, CURLOPT_URL, $url);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// set the username and password
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
// optional
// optional
// optional
curl_setopt($ch, CURLOPT_CAINFO, "/path/CertSigningAuthority.crt");

// Get the response and close the channel.
$reply = curl_exec($ch);
$info = curl_getinfo($ch);
echo '<pre>';
echo '</pre>';


Site Timeline