I'm developing a web site which will retrieve SMS messages that have been sent to a gateway. The gateway is accessed via an API, with the requests in the following format:
http://www.smsgateway.com/?login=myusername&password=mypassword&lasttime=1236164238
Notice that I'm having to track the last time messages were downloaded - only messages received after that time are returned.
The problem is that there's a time difference of about 5 minutes between the servers! Here's what's happening:
->User sends SMS; gateway server timestamps it at 11.00am (let's say actual time is 10.55am)
->My server requests all messages sent from 10.56 onwards - receives the above message and adds it to database
->My server requests all messages sent from 10.58 onwards - receives the above message and adds it again, since it is timestamped at 11.00am
->My server sends another request at 11.00 - receives the message and adds it to the database once more
So my problem is that the one original message is being received 3 times.
Changing my server's time is do-able, but not the remote servers.
How can I handle this without checking to see if the message is already in the database?