forked from cyrusdavid/fortrabbit-timer-resetter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.php
37 lines (27 loc) · 879 Bytes
/
reset.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require 'vendor/autoload.php';
use Symfony\Component\DomCrawler\Crawler;
use Goutte\Client;
$client = new Client();
$client->getClient()->setConfig(array('debug' => true));
$crawler = $client->request('GET', 'https://my.fortrabbit.com/login/');
$form = $crawler->selectButton('Login')->form();
$form['data[Account][email]'] = getenv('FRB_USERNAME');
$form['data[Account][password]'] = getenv('FRB_PASSWORD');
$crawler = $client->submit($form);
$links = $crawler->filter('.listapp h1 a');
if ( ! $links->count())
{
echo 'No apps found.' . PHP_EOL;
exit(1);
}
$links->each(function($link) use ($client)
{
echo 'Resetting timer for app ' . $link->text() . '.';
$crawler = $client->click($link->link());
echo '.';
$form = $crawler->selectButton('Reset Timer')->form();
echo '.';
$client->submit($form);
echo ' Done' . PHP_EOL;
});