I'm trying to make a script to login into a particular website. Tmplinshi was kind enough to help get a working version in ahk but I think it will be better to port it to PHP to run it from a linux server.
Unfortunately, for some reason I don't understand, it's not working.
If anyone here knows PHP well and would like to help me I can send the script with login and password via pm.
Thanks!
Help with PHP login script
Help with PHP login script
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Re: Help with PHP login script
does the login expect post or get?
if get you can easily use
If post let me know i have some code somewhere that i will dig up
if get you can easily use
Code: Select all
header( 'Location: http://example.com/page?username=something&password=somepassword .... other params');
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: Help with PHP login script
Thanks for the reply, tank!
I'm using POST to send the login information but I need to use GET before to retrieve a token. I've used wireshark to intercept the messages from both ahk and php, and although they seem identical I always get the login page in response when using php. I've tried with and without curl, following examples on the internet.
I'll send you a link to the script via pm.
Thanks again.
I'm using POST to send the login information but I need to use GET before to retrieve a token. I've used wireshark to intercept the messages from both ahk and php, and although they seem identical I always get the login page in response when using php. I've tried with and without curl, following examples on the internet.
I'll send you a link to the script via pm.
Thanks again.
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Re: Help with PHP login script
perfect
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: Help with PHP login script
tank got it, right in the "noodles"...
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Help with PHP login script
Sorry havent forgotten you been busy with work. Ill fix you up before saturday
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: Help with PHP login script
I'll be glad if you could take a look, but me and a bunch of friends have been trying everything since yesterday and nothing seems to work...tank wrote:Sorry havent forgotten you been busy with work. Ill fix you up before saturday
I believe the site must be blocking PHP/cURL. I can get it working on ahk (even got it using the COM object now) but no luck with PHP.
I've decided to try another language and started learning and converting it to Python today. And I'm glad to inform that I have successfully created a script to log in the website using Python, thanks to the requests library (already tested on ubuntu as well).
I suppose PHP would still be a better option, though. So if you do find a way, please let me know! But my hopes are low at this point...
I hope I can integrate PHP and Python now!
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Re: Help with PHP login script
I have had better luck with this instead of cURL
Code: Select all
function post_request($url, $data, $referer='') {
// Convert the data array into URL Parameters like a=b&foo=bar etc.
$data = http_build_query($data);
// parse the given URL
$url = parse_url($url);
if ($url['scheme'] != 'http') {
die('Error: Only HTTP request are supported !');
}
// extract host and path:
$host = $url['host'];
$path = $url['path'];
// open a socket connection on port 80 - timeout: 30 sec
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if ($fp){
// send the request headers:
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
if ($referer != '')
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ". strlen($data) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
$result = '';
while(!feof($fp)) {
// receive the results of the request
$result .= fgets($fp, 128);
}
}
else {
return array(
'status' => 'err',
'error' => "$errstr ($errno)"
);
}
// close the socket connection:
fclose($fp);
// split the result header from the content
$result = explode("\r\n\r\n", $result, 2);
$header = isset($result[0]) ? $result[0] : '';
$content = isset($result[1]) ? $result[1] : '';
// return as structured array:
return array(
'status' => 'ok',
'header' => $header,
'content' => $content
);
}
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: Help with PHP login script
Thanks! I'll try it and let you know how it goes!
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Re: Help with PHP login script
I seem to be getting a wrong result...
The 'status' is ok but 'content' shows the number 139, then I get sent to the login page just like before...
Am I calling it correctly?
The 'status' is ok but 'content' shows the number 139, then I get sent to the login page just like before...
Am I calling it correctly?
Code: Select all
$data =
array
(
'username' => $login,
'password' => $pass,
'perslogin' => 'Y',
'token' => $token,
'tprefs1' => '',
'tprefs2' => ''
);
$response = post_request($loginUrl, $data, $loginUrl);
echo $response["content"];
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
Return to “Other Programming Languages”
Who is online
Users browsing this forum: No registered users and 3 guests