Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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(""); $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.

Spread Firefox

Replies are listed 'Best First'.
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


    All code is usually tested, but rarely trusted.
Re: Get notified of Paypal balance changes
by zentara (Archbishop) on Nov 17, 2004 at 12:45 UTC
    Shouldn't that be ? 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 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 :(

      Spread Firefox
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 Just ask!!!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://408240]
Approved by ysth
Front-paged by grinder
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2018-06-21 20:54 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (119 votes). Check out past polls.