mbeals Posted May 5, 2010 Share Posted May 5, 2010 I have some equipment at remote sites that is managed by an appliance with an HTTP interface. I'm working on an automated script to log into the HTTP interface and fetch the status of the attached equipment. The appliance uses GET based, plain text authentication (not the best, but we have it IP locked over a secure link). I can successfully connect to the appliance and fetch the HTML containing the info I need, but the session is hanging, and causing the appliance to lock out any other sessions for a period of time. I know the session is hanging, because I can watch is stuck in ACK-FIN with lsof. I think the problem is the session is being abandoned after the initial login and data fetch, so when I issue the logout command, it initiates a new session, leaving the old one hanging (making the appliance think I'm still logged in). This is the code that I'm using: <?php $IP = 'xxx.xxx.xxx.xxx'; $user = 'admin'; $pass = 'xxx'; $login = "UserID=$user&Pwd=$pass"; $info = "HeadendStatus.htm?"; $logout = "LOGIN.htm?LOGOFF=LOG+OFF&"; //Fetch Status $ch = curl_init("http://$IP/".$info.$login); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); $data = curl_exec($ch); //Log out curl_setopt($ch, CURLOPT_URL,"http://$IP/".$logout.$login); $result=curl_exec($ch); curl_close($ch); // Process data..... ?> So, any thoughts on how to simulate login->fetch data->log out with curl, or any other functions? Quote Link to comment https://forums.phpfreaks.com/topic/200809-stupid-curl-question/ Share on other sites More sharing options...
teamatomic Posted May 5, 2010 Share Posted May 5, 2010 If you are using a GET you dont really need curl. After you get the results and close curl try sending the url via something like file_get_contents("http://$IP/$logout$login"); HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/200809-stupid-curl-question/#findComment-1053732 Share on other sites More sharing options...
mbeals Posted May 5, 2010 Author Share Posted May 5, 2010 Thanks. strangely enough, just using a single file_get_contents() call worked perfectly. No clue why CURL was giving me so many problems. Quote Link to comment https://forums.phpfreaks.com/topic/200809-stupid-curl-question/#findComment-1053768 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.