[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

basic cURL question

Here is my code:

$curl_handle = curl_init($url) or die('You need cURL installed to use this tool.');
curl_setopt($curl_handle, CURLOPT_HEADER, 0);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);

How do I get the response comming from that url? (And I don't want to set returntransfer to 0.)
Huji
0
huji
Asked:
huji
  • 2
1 Solution
 
star_trekCommented:
<?php  
   $curl_handle = curl_init($url);
   curl_exec($curl_handle);
   $info = curl_getinfo($curl_handle);
   print_r ($info);
?>
0
 
hujiAuthor Commented:
It is returning something like this:

Array ( [url] => http://www.google.com/ [content_type] => text/html [http_code] => 200 [header_size] => 302 [request_size] => 101 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 1.125 [namelookup_time] => 0.016 [connect_time] => 0.438 [pretransfer_time] => 0.438 [size_upload] => 0 [size_download] => 3042 [speed_download] => 2704 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 0 [starttransfer_time] => 0.906 [redirect_time] => 0 )

The page content (the HTML in this case) is not there.
0
 
hujiAuthor Commented:
I've found my mistake. Everything except the content is there. I get the header the way I usually do:
print curl_exec($curl_handle);
Thanks for your help.
Huji
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now