ttocskcaj Posted June 18, 2011 Share Posted June 18, 2011 I have this code: error_reporting(E_ALL); $post = array(); $post['user'] = "ttocskcaj"; $post['group'] = "Mod"; $ret = ''; $postdata_str = "user=" . $post['user'] . "&group=" . $post['group']; if (($fp = @fsockopen("www.secret.com", 8101, $errno, $errstr)) == false) die("Error $errno: $errstr\n"); fputs($fp, "POST /permissions-proceed HTTP/1.0\r\n"); fputs($fp, "Host: www.secret.com:8101"); fputs($fp, "User-Agent: HTTPTool/1.0\r\n"); fputs($fp, "Content-Length: 256\r\n\r\n"); fputs($fp, "$postdata_str"); while (!feof($fp)) { // receive the results of the request echo "<pre>".fgets($fp, 128)."</pre>"; } fclose($fp); Which is supposed to send a username and a group to a python script where the user is put into that group. It's not working though. I just want to check if everything is alright on this end, before trying to find what's wrong in the python. Link to comment https://forums.phpfreaks.com/topic/239724-http-request-not-working/ Share on other sites More sharing options...
redixx Posted June 18, 2011 Share Posted June 18, 2011 What does "not working" mean? Are you getting an error? Link to comment https://forums.phpfreaks.com/topic/239724-http-request-not-working/#findComment-1231446 Share on other sites More sharing options...
xyph Posted June 18, 2011 Share Posted June 18, 2011 Take the @ off of @fsockopen. That is an error suppressor Link to comment https://forums.phpfreaks.com/topic/239724-http-request-not-working/#findComment-1231526 Share on other sites More sharing options...
ttocskcaj Posted June 19, 2011 Author Share Posted June 19, 2011 There's no errors. I'm pretty sure it's the python that's not working. I just wanted to confirm that that php is fine Link to comment https://forums.phpfreaks.com/topic/239724-http-request-not-working/#findComment-1231611 Share on other sites More sharing options...
xyph Posted June 19, 2011 Share Posted June 19, 2011 Looks okay. Link to comment https://forums.phpfreaks.com/topic/239724-http-request-not-working/#findComment-1231624 Share on other sites More sharing options...
ttocskcaj Posted June 20, 2011 Author Share Posted June 20, 2011 Not sure what I was doing wrong, but I changed it to use cURL and now it works fine :s $survival_curl = curl_init(); curl_setopt($survival_curl, CURLOPT_URL, "http://www.secret.com"); curl_setopt($survival_curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($survival_curl, CURLOPT_POST, true); curl_setopt($survival_curl, CURLOPT_POSTFIELDS, $data); $output_survival = curl_exec($survival_curl); $info_survival = curl_getinfo($survival_curl); curl_close($survival_curl); Link to comment https://forums.phpfreaks.com/topic/239724-http-request-not-working/#findComment-1232121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.