August 2003
Beginner
368 pages
9h 38m
English
Send payment instructions to your customers automatically.
Here’s a simple script that will scan all your auctions that have ended in the last 24 hours and send a payment-instructions email to each high bidder.
This script requires the email template from [Hack #74]; just place it in the directory
specified by $localdir in your
config.pl include file.
#!/usr/bin/perl require 'ebay.pl'; $template = "template.txt"; $today = &formatdate(time); $yesterday = &formatdate(time - 864000); my $page_number = 1; PAGE: while (1) { my $rsp = call_api({ Verb => 'GetSellerList', DetailLevel => 8, UserId => $user_id, EndTimeFrom => $yesterday, EndTimeTo => $today, PageNumber => $page_number }); if ($rsp->{Errors}) { print_error($rsp); last PAGE; } foreach (@{$rsp->{SellerList}{Item}}) { my %i = %$_; ($id, $title, $currency, $price, $highbidder, $checkout) = @i{qw/Id Title CurrencyId CurrentPrice HighBidder Checkout/}; $bidderemail = $highbidder->{User}{Email}; if ($bidderemail =~ "\@") { $shipping = $checkout->{Details}{ShippingHandlingCosts}; $total = $price + $shipping; open(MAIL,"|/usr/sbin/sendmail -t"); print MAIL "To: $bidderemail\n"; print MAIL "From: $selleremail\n"; print MAIL "Reply-To: $selleremail\n"; print MAIL "Subject: $title\n\n"; open (COVER, "$localdir/$template"); while ( $line = <COVER> ) { if ($line eq "<insert title here>\n") { print MAIL $title; } elsif ($line eq "<insert item here>\n") { print MAIL $id; } elsif ($line eq "<insert ...