johnsmith153 Posted October 24, 2008 Share Posted October 24, 2008 If I type in https://www.site.com/page.php?var1=1&var2=5&var3= in my browser, I get exactly what I want. If I use below, it doesn't work. Surely both these are the same. $post_fields="var1=1&var2=5&var3="; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.site.com/page.php'); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response_string = curl_exec($ch); curl_close($ch); There are no $_GET requests on the target page - I have used $_REQUEST for all. Link to comment https://forums.phpfreaks.com/topic/130019-curl/ Share on other sites More sharing options...
xtopolis Posted October 25, 2008 Share Posted October 25, 2008 There are multiple comments about this if you read the manual. The difference is your SSL connection attempt using cURL. http://us2.php.net/manual/en/function.curl-setopt.php#76219 http://us2.php.net/manual/en/function.curl-setopt.php#76047 Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674138 Share on other sites More sharing options...
johnsmith153 Posted October 25, 2008 Author Share Posted October 25, 2008 I have removed the need for SSL and used http:// - didn't need it actually - long story. But still the same problem. It doesn't return anything in $response_string - just blank, but no success. Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674146 Share on other sites More sharing options...
xtopolis Posted October 25, 2008 Share Posted October 25, 2008 It works for me... test.php <?php $post_fields="var1=1&var2=5&var3="; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.mysite/test2.php'); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response_string = curl_exec($ch); curl_close($ch); echo '<textarea rows="50" cols="100">'.$response_string.'</textarea>'; ?> test2.php <?php print_r($_REQUEST); ?> Outputs: Array ( [var1] => 1 [var2] => 5 [var3] => ) ---- If you are returning HTML, are you sure it's just not visible? Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674149 Share on other sites More sharing options...
johnsmith153 Posted October 25, 2008 Author Share Posted October 25, 2008 Ok, here's the problem... Nothing to do with Curl (cURL) The target page has $_SESSION checks to check if user is logged in. I am logged in... but not according to cURL. It says I am not logged in. Is this obvious, or is there a way around it? Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674155 Share on other sites More sharing options...
johnsmith153 Posted October 25, 2008 Author Share Posted October 25, 2008 They key thing is that I ned to also retrieve and change session variables - otherwise I could send a POST value like: overideLoginCheck=fjrhghe4rg4gh to overide. I suppose this post should have been called: Need to pull/change session vars whilst using cURL Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674156 Share on other sites More sharing options...
xtopolis Posted October 25, 2008 Share Posted October 25, 2008 Show us some code please. Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674158 Share on other sites More sharing options...
kenrbnsn Posted October 25, 2008 Share Posted October 25, 2008 Using cUrl starts another http session, so the $_SESSION array created by your page isn't available to it. Ken Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674168 Share on other sites More sharing options...
johnsmith153 Posted October 25, 2008 Author Share Posted October 25, 2008 Is there an alternative to cURL where I can get the session values? Everything is all on my same server. Link to comment https://forums.phpfreaks.com/topic/130019-curl/#findComment-674170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.