CMNetworx Posted February 9, 2007 Share Posted February 9, 2007 I am on a host that does not allow fopen Unlike my last host.. So I am trying to recreate the same result with curl, but I don't know how to pass get variables to the url.. Can anyone help? I know how to do this with post, but I need to be able to pass info using the Get method $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://examplewebsite.com/info.php?info=$info'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); Of course this doesn't work correctly because it asks the website for $info and not the actual variable.. With post It seems to pass fine $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://website.com/info.php?info=$info); curl_setopt($curl_handle,CURLOPT_POST,1); curl_setopt($curl_handle,CURLOPT_POSTFIELDS, 'info=$info'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); Link to comment https://forums.phpfreaks.com/topic/37842-solved-using-curl-to-retrieve-some-info/ Share on other sites More sharing options...
spfoonnewb Posted February 10, 2007 Share Posted February 10, 2007 Maybe try: <?php $info = "variable"; $url = "http://examplewebsite.com/info.php?info=".$info.""; $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,$url); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); ?> Link to comment https://forums.phpfreaks.com/topic/37842-solved-using-curl-to-retrieve-some-info/#findComment-181215 Share on other sites More sharing options...
CMNetworx Posted February 11, 2007 Author Share Posted February 11, 2007 Thanks for your help. Worked great, I was trying something like that at one point, but I had it a little wrong. For some reason I thought it was the other way around ." ". as opposed to ". ." Link to comment https://forums.phpfreaks.com/topic/37842-solved-using-curl-to-retrieve-some-info/#findComment-182140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.