The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mobile::Ads::AdSense - module to serve Google Adsense for Mobile ads

Version 0.1.0

SYNOPSIS

 use Mobile::Ads::AdSense;
 $ad = new Mobile::Ads::AdSense
 ($text,$link) = $ad->get_text_ad({
                                site    => 'Google AdSense site code',
                                remote  => $ENV{'HTTP_USER_AGENT'},
                                address => $ENV{'REMOTE_ADDR'},
                                text    => 'default ad text',
                                link    => 'default ad link',
                                });
 

DESCRIPTION

Mobile::Ads::AdSense provides an object oriented interface to serve advertisements from Google AdSense for Mobile in mobile sites. This is just a slightly altered version of the perl code found on Google's site.

new Mobile::Ads::AdSense

[$parent]

To reuse Mobile::Ads in multiple (subsequent) ad requests, you can pass a Mobile::Ads reference here. Instead of creating a new Mobile::Ads object, we will use the one you pass instead. This might save a little LWP::UserAgent creation/destruction time.

Parameters/Properties

site

=> Goggle Adsense site code, delivered by them. Something in the form off ``999''

remote

=> Remote User Agent ($ENV{'HTTP_USER_AGENT'}). In fact $ENV{'HTTP_USER_AGENT'} will be used if not supplied.

address

=> $ENV{'REMOTE_ADDR'}. All things about HTTP_USER_AGENT also apply here.

text

=> Should we fail to retrieve a real ad, this is the text of the ad displayed instead

=> Same with text, but for the ad's link.

Methods

get_text_ad

=> Does the actual fetching of a text ad for the site given. Refer to new for details Returns a list ($text_for_ad,$link_for_ad) value.

get_image_ad

=> Does the actual fetching of an image ad for the site given. Refer to new for details Returns a list ($text_for_ad,$link_for_ad,$image_url) value.

Revision History

 0.0.1 
        Initial Release
 0.0.2 
        Fixed stupid typo
 0.0.3 
        Didn't preserve default values on failure
 0.0.4
        All ua stuff put in Mobile::Ads
 0.0.5 
        $ua timeout set to 2 sec in $self->{'parent'}
 0.0.6 
        raw google output has some pitfalls. implemented XML::LibXML parsing
        of the returned ad code.
 0.0.7 
        slight problems with encoding in LibXML parsing
 0.0.8
        Aliased get_ad to get_adsense_ad
 0.0.9
        Option to reuse parent Mobile::Ads instead of creating anew
 0.1.0
        One could also use a reference to the parent... :)

BUGS

Thoughtlessly crafted to avoid having the same piece of code in several places. Could use lots of enhancements.

DISCLAIMER

This module borrowed its OO interface from Mail::Sender.pm Version : 0.8.00 which is available on CPAN.

AUTHOR

Thanos Chatziathanassiou <tchatzi@arx.net> http://www.arx.net

COPYRIGHT

Copyright (c) 2008 arx.net - Thanos Chatziathanassiou . All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 58:

You forgot a '=back' before '=head2'