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:

All of these functions take a channel ID as an optional parameter. Link units are also supported via these functions:

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”

  1. AdSensePHP: Easy AdSense Code Generation on May 28th, 2007 2:35 pm

    […] AdSensePHP a try and let me know what you think. The Introducing AdSensePHP post on the AdSensePHP.com site has more […]

  2. Paul on June 3rd, 2007 2:52 pm

    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

  3. Paul on June 3rd, 2007 2:54 pm

    Meh, obvioulsy it stripped the code >

  4. Eric Giguere on June 4th, 2007 9:29 pm

    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…

  5. Michael Martine on June 5th, 2007 5:35 pm

    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.

  6. Eric Giguere on June 5th, 2007 7:06 pm

    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.

  7. Michael Martine on June 5th, 2007 7:13 pm

    Ah, I see. Thanks for answering the question. :)

Leave a Reply