Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Anyone any good with PHP?
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Other forums
- :
- Tech Help - Software/Hardware etc
- :
- Anyone any good with PHP?
Anyone any good with PHP?
07-11-2011 4:01 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Basically, I'm using PHP to scrape usage stats from the portal, but authentication is proving somewhat problematic.
I made a little HTML page just so I could see the bare minimum needed to login, the following successfully logs in:
However doing (what I think is) the same in PHP yields an invalid password message every time.
Here is the PHP Code:
Hope someone can spot where I'm going wrong,
Alex
I made a little HTML page just so I could see the bare minimum needed to login, the following successfully logs in:
<form action="https://portal.plus.net/view_my_broadband_usage/index.php" method="post">
<input type="text" name="username"></input>
<input type="password" name="password"></input>
<input type="text" name="authentication_realm"></input>
<input type="submit"></input>
</form>
However doing (what I think is) the same in PHP yields an invalid password message every time.
Here is the PHP Code:
<?php
$url = 'https://portal.plus.net/view_my_broadband_usage/index.php';
//header('Content-Type: text/plain; charset=utf-8'); // optional
error_reporting(E_ALL | E_STRICT);
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => implode("\r\n", array(
'Content-type: application/x-www-form-urlencoded',
)),
'content' => http_build_query(array(
'username' => 'houlton23',
'authentication_realm' => 'portal.plus.net',
'password' => '<--password-->',
))
)
));
$page = file_get_contents($url, false, $context);
echo $page;
?>
Hope someone can spot where I'm going wrong,
Alex
1 REPLY 1
Re: Anyone any good with PHP?
07-11-2011 11:44 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Two lines of thought.
1) I think a Content-Length header is needed if the request is passed as HTTP/1.0; not sure whether that applies here or not.
2) Just wondering if the problem is that the login page is separate from VMBU (and other Member Centre pages) so a session token has to be passed from page to page to authenticate the user. A normal browser will handle this routinely but this 'pretend' browser would need to emulate the process.
1) I think a Content-Length header is needed if the request is passed as HTTP/1.0; not sure whether that applies here or not.
2) Just wondering if the problem is that the login page is separate from VMBU (and other Member Centre pages) so a session token has to be passed from page to page to authenticate the user. A normal browser will handle this routinely but this 'pretend' browser would need to emulate the process.
David
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Other forums
- :
- Tech Help - Software/Hardware etc
- :
- Anyone any good with PHP?