0

I'm struggling with php curl. This is the problem:

In the following code, if I pass $query as curl_init() parameter it doesn't work, and I get no error at all. But if I pass the exact content of $query to curl_init() the code works fine.

$query1 = "'user:[email protected]/cdtc-test/service.php/find/ca_objects?q=*'";
$curl = curl_init($query1);
$errmsg  = curl_error( $curl );
if (!$errmsg =='') {die($err.':'.$errmsg);}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$header  = curl_getinfo( $curl );
print_r ($header);
$result = curl_exec ($curl);
curl_close ($curl);  

The result of print_r ($header) shows that the url is passed. I can't figure out what's wrong. Any ideas? Thanks in advance.

Array ( [url] => 'user:[email protected]/cdtc-test/service.php/find/ca_objects?q=*'
[content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 
[filetime] => 0 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 
[namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0
[size_download] => 0 [speed_download] => 0 [speed_upload] => 0 
[download_content_length] => -1 [upload_content_length] => -1 
[starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => 
Array ( ) [redirect_url] => ) 

1 Answer 1

1

I believe that this:

$query1 = "'user:[email protected]/cdtc-test/service.php/find/ca_objects?q=*'";

Should be this (notice the removal of the inner single quotes):

$query1 = "user:[email protected]/cdtc-test/service.php/find/ca_objects?q=*";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.