I am not sure how rapidgator premium works, but if it automatically starts the download as soon as you open the url then you should be able to use cURL or fopen, doing a quick search this should help you get started:
Check out RapidLeech.
If they’ve improved their code at all, you may be able to use some sort of API.
You can use curl, but you also need to pass the cookies with a valid login session.
So first, use curl to login and save the cookie to a file. Next, use curl and pass that cookie along while requesting the download link.
I use this with my own upload/download script and it works pretty simply.
curl is very simple:
as you can see from the source code, rapidgator uses :
and sends the vars : LoginForm[email] LoginForm[password]
with that information it should be pretty simple for anyone to make a small wee script that takes the text entered into a textbox and pass it to RG , once done, keep the session and request a download using wget or fread or something similar