PHP curl script to fetch your aib accounts (Compilments of Jon (kudos) Cremin)
updated to work with visa validation by me!
Linux users can display this infromation neetly on your desktop using such applications as http://conky.sourceforge.net
Screenshot
Code
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | <?php class aib { public function __construct($regnumber, $challenge_phone, $challenge_visa, $pac) { $this->regnumber = $regnumber; $this->challenge_phone = $challenge_phone; $this->challenge_visa = $challenge_visa; $this->challenge = ""; $this->pac = str_split($pac); array_unshift($this->pac, null); $this->ch = curl_init(); curl_setopt( $this->ch , CURLOPT_RETURNTRANSFER , 1 ); curl_setopt( $this->ch , CURLOPT_SSL_VERIFYPEER , 0 ); curl_setopt( $this->ch , CURLOPT_COOKIEFILE , ".cookiefile" ); curl_setopt( $this->ch , CURLOPT_COOKIEJAR , ".cookiefile" ); curl_setopt( $this->ch , CURLOPT_FOLLOWLOCATION , 1 ); curl_setopt( $this->ch , CURLOPT_USERAGENT , "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-gb) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17" ); } public function balances() { curl_setopt( $this->ch , CURLOPT_URL , "https://aibinternetbanking.aib.ie/inet/roi/login.htm" ); $output = curl_exec( $this->ch ); preg_match( '@id="transactionToken" value="(.*)"@' , $output , $token ); curl_setopt( $this->ch , CURLOPT_POST , 1 ); curl_setopt( $this->ch , CURLOPT_POSTFIELDS , "jsEnabled=TRUE&transactionToken=" . $token[1] . "®Number=".$this->regnumber."&_target1=true" ); curl_setopt( $this->ch , CURLOPT_URL , "https://aibinternetbanking.aib.ie/inet/roi/login.htm" ); $output = curl_exec( $this->ch ); preg_match( '@id="transactionToken" value="(.*)"@' , $output, $token); preg_match( '@<label for="digit1"><strong>Digit (.*)</strong></label>@' , $output , $pac1 ); preg_match( '@<label for="digit2"><strong>Digit (.*)</strong></label>@' , $output , $pac2 ); preg_match( '@<label for="digit3"><strong>Digit (.*)</strong></label>@' , $output , $pac3 ); $this->challenge = preg_match( "/home phone number/" , $output ) > 0 ? $this->challenge_phone : $this->challenge_visa ; $postinfo = "_finish=true&transactionToken=" . $token[1]; $postinfo .= "®Number=" . $this->regnumber; $postinfo .= "&pacDetails.pacDigit1=" . $this->pac{$pac1[1]}; $postinfo .= "&pacDetails.pacDigit2=".$this->pac{$pac2[1]}; $postinfo .= "&pacDetails.pacDigit3=" . $this->pac{$pac3[1]}; $postinfo .= "&challengeDetails.challengeEntered=".$this->challenge; curl_setopt( $this->ch , CURLOPT_POST , 1 ); curl_setopt( $this->ch , CURLOPT_POSTFIELDS , $postinfo ); curl_setopt( $this->ch , CURLOPT_URL , "https://aibinternetbanking.aib.ie/inet/roi/login.htm" ); $output = curl_exec( $this->ch ); if( preg_match( "/continue to account overview/" , $output ) > 0 ) { preg_match( '@id="transactionToken" value="(.*)"@' , $output , $token ); curl_setopt( $this->ch , CURLOPT_POST , 1 ); curl_setopt( $this->ch , CURLOPT_POSTFIELDS , "iBankFormSubmission=false&transactionToken=" . $token[1] ); curl_setopt( $this->ch , CURLOPT_URL , "https://aibinternetbanking.aib.ie/inet/roi/accountoverview.htm" ); $output = curl_exec( $this->ch ); } $output = str_replace( "\n" , "" , $output ); $output = str_replace( "\r" , "" , $output ); preg_match_all( '@<img src="/roi/_img/buttons/plus_pl_db.gif" alt="expand" />(.*?)<span>(.*?)</span>@s', $output , $names ); preg_match_all( '@<h3>(.*?)</h3>@s' , $output , $bal ); for( $i = 0; isset( $names[2][$i] ); $i++ ) { $accounts[] = array( "name" => $names[2][$i] , "balance" => str_replace( " " , "" , str_replace( " " , "" , $bal[1][$i] ) ) ); } return $accounts; } public function __destruct() { curl_close( $this->ch ); } } $regnumber = "88888888"; $challenge_phone = "4444"; $challenge_visa = "2222"; $pac = "77777"; $aib = new aib($regnumber, $challenge_phone, $challenge_visa, $pac); $accounts = $aib->balances(); foreach((array)$accounts as $account) { echo trim($account['name']) . "\${goto 150}" . trim($account['balance']) . "\n\n"; } ?> |