Jump to content

Recommended Posts

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? 

Link to comment
https://forums.phpfreaks.com/topic/200809-stupid-curl-question/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.