设置自动登录/访问特定的URL


Setup Auto-Login/Visit Specific URL?

有一个网站,我想登录总是看到7/24在线,因为用户之间有一个队列,如果你经常在线,你就会在这个队列中前进。我有一个linux服务器,我计划使用这个原因,但到目前为止,我找不到任何有用的从谷歌。如果你能帮助我,我会很高兴的!

总结:我的服务器将永远登录到网站,我将被看到在线,甚至在凌晨3点。

使用cURL登录并获得会话(来自Internet的示例代码):

$username = 'myuser';
$password = 'mypass';
$loginUrl = 'http://www.example.com/login/';
//init curl
$ch = curl_init();
//Set the URL to work with
curl_setopt($ch, CURLOPT_URL, $loginUrl);
// ENABLE HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);
//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, 'user='.$username.'&pass='.$password);
//Handle cookies for the login
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
//not to print out the results of its query.
//Instead, it will return the results as a string return value
//from curl_exec() instead of the usual true/false.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//execute the request (the login)
$store = curl_exec($ch);
//the login is now done and you can continue to get the
//protected content.
//set the URL to the protected file
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/protected/download.zip');
//execute the request
$content = curl_exec($ch);
curl_close($ch);

然后您可以稍后使用这个cookie文件,并且可以只使用cURL发出get请求-例如每半小时一次。如果您试图登录的站点使用令牌,那么您应该在登录之前发出get请求。(我在一所大学的在线学习系统中也遇到过同样的问题,教授可以看到你看了多长时间的内容:-D)