CURL_EXEC(3) 1 CURL_EXEC(3)curl_exec - Perform a cURL sessionSYNOPSIS
mixed curl_exec (resource $ch)
DESCRIPTION
Execute the given cURL session.
This function should be called after initializing a cURL session and all the options for the session are set.
PARAMETERS
o $ch
-A cURL handle returned by curl_init(3).
RETURN VALUES
Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success,
FALSE on failure.
EXAMPLES
Example #1
Fetching a web page
<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>
SEE ALSO curl_multi_exec(3).
PHP Documentation Group CURL_EXEC(3)
Check Out this Related Man Page
CURL_SETOPT_ARRAY(3) 1 CURL_SETOPT_ARRAY(3)curl_setopt_array - Set multiple options for a cURL transferSYNOPSIS
bool curl_setopt_array (resource $ch, array $options)
DESCRIPTION
Sets multiple options for a cURL session. This function is useful for setting a large amount of cURL options without repetitively calling
curl_setopt(3).
PARAMETERS
o $ch
-A cURL handle returned by curl_init(3).
o $options
- An array specifying which options to set and their values. The keys should be valid curl_setopt(3) constants or their integer
equivalents.
RETURN VALUES
Returns TRUE if all options were successfully set. If an option could not be successfully set, FALSE is immediately returned, ignoring any
future options in the $options array.
EXAMPLES
Example #1
Initializing a new cURL session and fetching a web page
<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
$options = array(CURLOPT_URL => 'http://www.example.com/',
CURLOPT_HEADER => false
);
curl_setopt_array($ch, $options);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>
Prior to PHP 5.1.3 this function can be simulated with:
Example #2
Our own implementation of curl_setopt_array(3)
<?php
if (!function_exists('curl_setopt_array')) {
function curl_setopt_array(&$ch, $curl_options)
{
foreach ($curl_options as $option => $value) {
if (!curl_setopt($ch, $option, $value)) {
return false;
}
}
return true;
}
}
?>
NOTES
Note
As with curl_setopt(3), passing an array to CURLOPT_POST will encode the data as multipart/form-data, while passing a URL-encoded
string will encode the data as application/x-www-form-urlencoded.
SEE ALSO curl_setopt(3).
PHP Documentation Group CURL_SETOPT_ARRAY(3)
Hi everybody, it's me again http://phpbuilder.com/board/images/smilies/smile.gif
I'm currently working on a script that will show a website visitor pictures of their location. The pictures come from the Flickr API and the address is grabbed from HostIP.
<?php
define('SORT',... (2 Replies)
Hi
I need once again you help guys,
I have a php script that should call and url on the local-server, when i call the script from the browser it just prints the $str and it doesn't call the url, but when i execute the script from the shell (php sentdata.php) it works.
I checked the apache... (6 Replies)
Hi everybody, I need the help of the Unix community once again :)
I have some code which queries an XML feed and displays the results for me. I would like to enter the XML output in to my database, but I am having trouble passing the variables while INSERTing.
Here is my code that I need to... (0 Replies)
Hi all..
can u please let me know how to use the unix shell curl command in PHP scripting,
sample of my code is given below,
<?php
$ch = shell_exec('curl -H "Content-type: application/json" -H "Accept: application/json" --data-binary '{"text" : "how to check the temperature?"}' -H... (5 Replies)
Hello unix.com
I want to use curl to post some logs to a remote server using curl.
$ch = curl_init("http://example.com/post/post.php");
curl_setopt($ch, CURLOPT_POST ,1);
curl_setopt($ch, CURLOPT_POSTFIELDS ,"FOUT=hash.gif&DATA=$message");
curl_setopt($ch, CURLOPT_HEADER ... (4 Replies)
Hi,
Can anybody help to solve this. I want to parse some xmldata along with the URL in the Shell.
I'm calling the URL via the curl command
Given below is my shell script file
export... (7 Replies)
Hello,
I am using IMDB bot file for my movie site..
But I get this message like this---Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in... (2 Replies)
Hi i have a php script that works 100% however i don't want this to run on php because of server limits etc. Ideally if i could convert this simple php script to a shell script i can set it up to run on a cron. My mac server has curl on it. So i am assuming i should be using this to download the... (3 Replies)
How can we empty or replace with null, following block of code (within the php quotes including the quotes) from inside a file.
*** some other data above this code
<?
#317008#
... (5 Replies)
The sample file:
dept1: user1,user2,user3
dept2: user4,user5,user6
dept3: user7,user8,user9
I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Hello.
I have pick up a script from internet to track errors from curl command.
#!/bin/bash
#
URL_TO_TEST="http://www.xxxxxx.yyy"
MY_VAR=curl_init("$URL_TO_TEST") ;
curl_setopt($MY_VAR, CURLOPT_HEADER, 1);
curl_setopt($MY_VAR, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($MY_VAR,... (2 Replies)