Pain Posted August 12, 2014 Share Posted August 12, 2014 Hi. I am fairly new with cURL. I have a URL like example.com/index.php?something=value&somethingtwo=valuetwo How can I get those values and print them out? I've got this code, but have no idea what to do next, please help guys! <?php function get($url, $params=array()) { $url = $url.'?'.http_build_query($params, '', '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); return $response; } // Sample call echo get('https://www.example.com/index.php', array('something'=>'value', 'somethingtwo'=>'valuetwo')); ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted August 12, 2014 Share Posted August 12, 2014 How can I get those values and print them out?By executing code. If you don't want to explain what you're talking about then you'll have to wait until somebody else here explains it for you. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 12, 2014 Share Posted August 12, 2014 (edited) First of all: Guys, please, please stop copying and pasting crap code you found somewhere on the Internet. I understand that you're new to cURL. But the answer to this problem is to learn, not adopt the first piece of code you've stumbled upon. After 4 years, you should know that most code is plain crap and pretty much the last thing you want on your server. This line silently breaks the security of all HTTPS connections by turning off certificate verification: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); That's obviously a very, very bad idea, because the whole reason for using HTTPS is security. Even worse, this “feature” isn't documented anywhere in the code you've posted. It just sits there waiting to take effect when you least expect it. Actually, the only reason why this option is used at all is because people don't know how to set up HTTPS, run into an error and decide to “solve” this problem by effectively deactivating HTTPS. How intelligent. So don't use the code. Take some time to learn cURL and then write your own code. How can I get those values and print them out? Get which values? Edited August 12, 2014 by Jacques1 Quote Link to comment Share on other sites More sharing options...
Zane Posted August 12, 2014 Share Posted August 12, 2014 echo "<pre>", print_r($_GET), "</pre>"; This is just a start. It will show you what $_GET contains, in a clean, readable format. To get the values, simply grab it with $_GET['thekeyname'] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.