Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Get notified of Paypal balance changes

by silent11 (Vicar)
on Nov 16, 2004 at 20:50 UTC ( #408240=CUFP: print w/ replies, xml ) Need Help??

I use this to send txt messages to my cell when my Paypal balance changes.
#!/usr/bin/perl # silent11 # 11/16/2004 use strict; use warnings; my $paypal_email = ""; my $paypal_pass = ""; my $notify_from = ""; my $notify_to = ""; my $balance_file = "balance.txt"; my $balance = return_balance(); # # # Get notified via email (or cell phone txt msg) # # # of Paypal balance changes notify_me( $balance ) if compare( $balance ); # # # Subs # # # sub return_balance { use WWW::Mechanize; my $browser = WWW::Mechanize->new(); $browser->get("https://www.paypal.com/"); $browser->form(1); $browser->field("login_email", $paypal_email); $browser->field("login_password", $paypal_pass); $browser->click(); $browser->follow("click here to reload"); my $html = $browser->content; # Please don't laugh at the regex ;^) It works! $html =~ /(.*history">\$)(\d+\.\d+) (USD)/s; return $2; } sub compare { use Tie::File; # First time to use Tie::File # very cool! tie my @balance, 'Tie::File', $balance_file || die $!; my $new_balance = shift; my $cur_balance = $balance[0]; $balance[0] = $new_balance; untie @balance; return 1 if ($new_balance != $cur_balance); } sub notify_me { use MIME::Lite; my $msg = MIME::Lite->new( From => $notify_from, To => $notify_to, Subject => 'Paypal Balance', Data => $balance ); $msg->send || die $!; }

Update: changed http to https per zentra's suggestion.



-silent11
Spread Firefox

Comment on Get notified of Paypal balance changes
Download Code
•Re: Get notified of Paypal balance changes
by merlyn (Sage) on Nov 16, 2004 at 23:32 UTC

      ...I get notified about every 20 minutes...


      I've got it set to check once an hour.

      Unfortunately it's only notified me once since writing this :(


      -silent11
      Spread Firefox
Re: Get notified of Paypal balance changes
by zentara (Archbishop) on Nov 17, 2004 at 12:45 UTC
    Shouldn't that be https://www.paypal.com/ ? It looks like it redirects you automatically, but I feel better when I see https when LOGIN_PASSWORD is in a script.

    I'm not really a human, but I play one on earth. flash japh
Re: Get notified of Paypal balance changes
by b10m (Vicar) on Nov 17, 2004 at 13:00 UTC

    Wouldn't it be easier to have the paypal server contact yours in case any changes are made? This is possible through IPN (Instant Payment Notification). Saves bandwidth (and other possible errors). And to make this more 'perly', there's of course a module for it: Business::PayPal::IPN

    --
    b10m

    All code is usually tested, but rarely trusted.
Re: Get notified of Paypal balance changes
by ghenry (Vicar) on Nov 21, 2004 at 21:26 UTC
    Shouldn't they be '' instead of "", so I don't have to \@ for the e-mails? Just learning ;-)
    Just getting into the best language ever... Fancy a yourname@perl.me.uk? Just ask!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://408240]
Approved by ysth
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-28 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls