Automatic web login
Brought to you by:
macdome
It would be nice to have automatic web login from
the application, as is seen in sputnix 0.6b and
later.
This would require figuring out how to send a post
request via Cocoa. Something which should not
be very difficult.
The form to do so should be deciferable from the
Audiogalaxy website.
Logged In: YES
user_id=151346
I looked at this last night and found that this could be
implemented in the current code by just adding the
values:
loginUsername=
loginPassword=
to the end of any current GET request.
Sputnix however seems to use POST to first get you
logged in and then take you to the correct page. That
seems like a slicker way to do it, and therefore I have
refrained from adding this feature to 1.1
Suggestions are always appreciated.
Logged In: YES
user_id=31953
Hi there. Here's some login code (in Perl, though easily
translatable to C I suppose) I wrote for the Unweb project.
I used the GET method. POST
sub login
{
my ($login, $passwd) = @_;
my ($request, $response, $cookie, $content, $sid);
# $SERVER/?loginUsername=...&loginPassword=...
$request = HTTP::Request->new('GET',
"$SERVER/?loginUsername=$login&loginPassword=$passwd");
$response = $ua->request($request);
$cookie = $response->header("Set-Cookie");
$content = $response->content;
open(LOG,">out.html")||die;print LOG $content;close
(LOG);
if ($content !~ m/welcome&nbsp;<span
class=username>$login/ # Gold
and$content !~ m/$login<\/span>&nbsp;home/) #
Regular
{
die "login failure $login, see out.html for
details";
}
($sid) = $cookie =~ m/SID=([^;]+)/;
return "SID=$sid; cookieUsername=$login;
cookiePassword=$passwd";
}
Once you have the cookie, simply send it with all requests
for other site functions. So far I implemented:
- Login via /
- Searching via /list/searches.php
- Song title via /list/song.php
- Version selection via /list/chooseVersion.php
- Queuing via /list/chooseVersion.php
- Song sending via via /groups/sendSongToMembers.php
- Multiple song sending
- Note reading via /user/allNotes.php
- Post reading via /pages/thread.php?t=$tid
If you're interested, I can provide you with the code. Very
useful for automating certain functions, and perhaps for
providing an alternative to using a web browser.