Introducing AdSensePHP
Today I introduce a set of PHP scripts I call AdSensePHP. These scripts, available in Lite (free) and Pro (commercial) versions, let you easily insert AdSense code into your website or blog pages. After configuring the script with your AdSense publisher ID and default settings, all you do is insert code like this into your pages:
<?php echo adsensephp_large_rectangle(); ?>
The generated code is identical to what you’d get from your AdSense console.
The Lite version provides basic functionality. The Pro version adds support for things like channel names, color palettes,
referral units, and other features.
Installation
For the Lite version, download adsensephp-lite.zip, unzip its contents onto your web server and include the adsensephp-lite.php file as required to access the AdSensePHP functions.
The Pro version is still under development.
Usage
All ad unit formats are supported via the following PHP functions:
- adsensephp_leaderboard()
- adsensephp_banner()
- adsensephp_half_banner()
- adsensephp_skyscraper()
- adsensephp_wide_skyscraper()
- adsensephp_vertical_banner()
- adsensephp_large_rectangle()
- adsensephp_medium_rectangle()
- adsensephp_square()
- adsensephp_small_square()
- adsensephp_small_rectangle()
- adsensephp_button()
All of these functions take a channel ID as an optional parameter. Link units are also supported via these functions:
- adsensephp_horizontal_linkunit()
- adsensephp_vertical_linkunit()
The link unit functions take a width parameter as well as optional number of ads (4 or 5) and channel parameters.
If you want more flexibility, the adsensephp_adunit() and adsensephp_linkunit() functions are also available.
For now, the only documentation is in the PHP source code. More to come, though!
Licensing
AdSensePHP Lite is free for anyone to use. You can even bundle it with WordPress themes or whatever. No link back is required, although of course any links are appreciated!
AdSensePHP Pro is a commercial product. Initially it will only be available (when it’s ready!) to purchasers of Uncommon AdSense.
Comments and suggestions are appreciated. Either leave them here on this blog or else drop me a note.
To see the script in action, just view the source of any page on this site. All the ads are generated using AdSensePHP of course!
Comments
7 Responses to “Introducing AdSensePHP”
Leave a Reply

[…] AdSensePHP a try and let me know what you think. The Introducing AdSensePHP post on the AdSensePHP.com site has more […]
Have to say Eric, a call to ones Adsense code is just as easy with something like:
Careful with your wording for the new product though mon ami, your new Uncommon Adsense sounds interesting but it reads like you are advocating MFA sites…
“How to always target the best and most relevant ads”
and
“How to properly use high-paying keyword lists”
Some of the other parts sound interesting though.
~ Paul
Meh, obvioulsy it stripped the code >
Well, when you’re building a lot of sites I just find my little scripts easier to use.
And no, my book isn’t about building MFA sites… trust me, look over all the free content I have over on Make Easy Money with Google and AdSense and you’ll see what I mean…
I can see how this might be useful for a static site or if you really just don’t know anything about PHP (I’m no programmer, but I can do an include and know my WP template tags). So, how does it get the ads’ color palette?
PS — good job on the new WP blog. I love WP.
You have to configure the Pro script to use the appropriate colors and so on, although I provide a reasonable list of defaults…. I’m not saying this is rocket science, but I find it useful so I thought others would, too.
Ah, I see. Thanks for answering the question.