The Ha7net (1-wire controller accessed via TCP/IP) offers the option to set a user password. The problem is that the documentation doesn't bother to tell you how to send the username/password.
When reading HTML from the Ha7net via a browser, I found that Firefox was happy if I just appended "&user=user&password=pword" (you can change "pword" but not "user"). But IE8 still threw up a dialogue box asking for the two entries. And in php file_get_contents failed with a 401 error.
The solution is that the username/password need to be submitted in encoded form. Here is an example in php:
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode(USER_NAME.":".USER_PASSWORD)
)
));
return file_get_contents($url, false, $context);
I have suggested to eds that the manual needs some content on use of passwords. For now, I hope this might just save someone else a bit of time.
Thursday 3 February 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment