viewing curl options

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

viewing curl options

Post by raghavan20 »

let us say we created a curl resource and set options on it. we can see whether option is set or not by printing return of curl_setopt() but I want to know all the options that have been set a curl resource at any point of time, how do I do that?
for ex:
if i have set CURLOPT_URL
CURLOPT_POST
CURLOPT_POSTDATA
CURLOPT_FOLLOWLOCATION

i want some way to list all the options set on a given curl resource....how?
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

2. this simple curl code does not seem to POST but it reaches the target URL...can you tell me why?

Code: Select all

$ch = curl_init( 'http://sitename/curlTest/getPOST.php' );
curl_setopt( $ch, "CURLOPT_POST", 1 );
curl_setopt( $ch, "CURLOPT_POSTFIELDS", "fileName=uploadthisfile&size=23+Bytes" );
curl_setopt( $ch, "CURLOPT_RETURNTRANSFER", 1 );
echo curl_exec( $ch );
if (curl_errno($ch)) {
 	print curl_error($ch);
}
target file code

Code: Select all

<?php
echo "\n\nprinting the received post array:\n"; print_r( $_POST );

?>
result

Code: Select all

printing the received post array:
Array
(
)
1
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

i have solved the second one, the problem was i have put double quotes around options which is not allowed.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh, you could just keep track of the settings you use.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

but i want to know whether the option set has been accepted or not. because the second problem, where i put curl options in double quotes, it returned boolean 1 but it was supposed to give 0 for those..i cant really rely ont hte output of curl_setopt()
Post Reply