A Donation FeedFlare for FeedBurner

Update: I have released the PHP source code for the PayPal donation FeedFlare I wrote. Please feel free to use it (edit as needed, and host on your server). You can find the source code at the end of this blog post.

FeedBurner, the processor for my blog’s feed, has a really cool feed optimization extension called FeedFlare (under the Optimize menu in your account). It allows additional links to be dynamically added under each feed item (see the catalog of available FeedFlare’s). Moreover, the FeedFlare API allows developers to create new FeedFlares (XML scripts) and integrate them with their feeds through FeedBurner.

So trying out the possibilities, I created a new FeedFlare which allows the feed subscribers to make a donation via PayPal. The “Donate via PayPal” FeedFlare adds a customized donation link below each feed item. This FeedFlare has the following customizable URL Parameters:

label -> link title (eg: Donate to XYZ etc.), if unspecified defaults to ‘Donate’;
msg -> message displayed on the PayPal payment page (eg: Donate to the XYZ Relief Fund etc.), if unspecified defaults to the FeedBurner blog feed title;
email -> PayPal e-mail address, if unspecified defaults to the FeedBurner author e-mail address;
curr -> currency code (eg: USD, GBP, EUR, AUD etc.), if unspecified defaults to USD;
locl -> locale ID (eg: US, UK, AU etc.), if unspecified defaults to US.

Usage example: https://www.nilkanth.com/feedflare/donate/?label=Donate to WorldVision&msg=Donation for WorldVision Children Fund&email=yourname@test.com&curr=AUD&locl=AU

PHP source code:

[code lang=”php”]
<?
// FeedBurner FeedFlare
// PayPalDonate v1 (3 Mar 2007)
// Developed by: Ashutosh Nilkanth (www.nilkanth.com)

$Tlabel = trim($_GET["label"]); // donation title message
$Tmsg = trim($_GET["msg"]); // donation title message
$Temail = trim($_GET["email"]); // PayPal email address
$Tcurr = trim($_GET["curr"]); // PayPal currency code
$Tloc = trim($_GET["locl"]); // PayPal currency code

if ( empty($Tlabel) )
$Tlabel = "Donate";

if ( empty($Tmsg) )
$Tmsg = "\${/a:feed/a:title}";
else
$Tmsg = urlencode($Tmsg);

if ( empty($Temail) )
$Temail = "\${(ancestor-or-self::*/a:author/a:email)[last()]}";
else
$Temail = urlencode($Temail);

if ( empty($Tcurr) )
$Tcurr = "USD";

if ( empty($Tloc) )
$Tloc = "US";

header("Content-Type: text/xml");
header("Pragma: no-cache");

echo "<!DOCTYPE FeedFlareUnit SYSTEM \"http://www.feedburner.com/fb/static/flareunits/FeedFlareUnit-1.0.dtd\">\n";
?>
<FeedFlareUnit>
<Catalog>
<Title>Donate via PayPal</Title>
<Description>Accept donations securely and conveniently using PayPal.com. Customizable URL Parameters: label -> link title (eg: Donate to XYZ etc.), if unspecified defaults to ‘Donate’; msg -> message displayed on the PayPal payment page (eg: Donate to the XYZ Relief Fund etc.), if unspecified defaults to the FeedBurner blog feed title; email -> PayPal e-mail address, if unspecified defaults to the FeedBurner author e-mail address; curr -> currency code (eg: USD, GBP, EUR, AUD etc.), if unspecified defaults to USD; locl -> locale ID (eg: US, UK, AU etc.), if unspecified defaults to US. Usage example: https://www.nilkanth.com/feedflare/donate/?label=Donate to WorldVision&amp;msg=Donation for worldVision Children Fund&amp;email=yourname@domain.com&amp;curr=AUD&amp;locl=AU</Description>
<Author>Ashutosh Nilkanth</Author>
</Catalog>
<FeedFlare>
<Text><?echo $Tlabel;?></Text>
<Link href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=<? echo $Temail;?>&amp;item_name=<?echo $Tmsg;?>&amp;no_shipping=0&amp;tax=0&amp;currency_code=<?echo urlencode($Tcurr);?>&amp;lc=<?echo urlencode($Tloc);?>&amp;bn=PP%2dDonationsBF&amp;charset=UTF%2d8" />
</FeedFlare>
</FeedFlareUnit>
[/code]

Show Comments