Authentication method via PHP script on my server

I am using a new service to pull XML data from a server.

The service provides two login methods, one via a URL request:

http://<server>/login.asp?username=<User Name>&password=<Password>

      

and the server returns a cookie that is valid for 7 days. This means that instead of logging in for every request (and making my script less efficient), I only need to log in once a week.

I just realized I cannot do this as the script is not run from the web browser but from a cron script on the server. Is there a way to store cookies on my server or do I need to go to the second method:

Marker

The token is the username, passwork and user group, encrypted using the DES algorithm with a key and timestamp. The token can be generated by any application using the DES algorithm using the appropriate key or safe you can use the call below: the token is contained in the body of the returned page and is valid for one hour

I don't know anything about this method. Can you point me in the right direction? Thanks.

Ed

0


a source to share


2 answers


Is there a way to store cookies on my server?

Yes. Here's how:

curl -c cookies.txt http://<server>/login.asp?username=<User Name>&password=<Password>

      



This will write them in netscape format to cookies.txt

.

Noah

+1


a source


If you have access to the actual login script, you can instead include some kind of unique identifier that you know.

Better yet would be to use some HMAC- (MD5 / SHA1) scheme like OpenAuth. If you are lazy, just add something like "? Key = somethingonlyyouknow" to every url you access, bypassing username + password. The user + password scheme "should" actually be used by humans, not machines.



If all of this fails, replace the script with storing the cookie. If you use "curl" you can specify which cookies should be stored and in which file should they be.

0


a source







All Articles