Google rolls out +1 on AdSense adverts

I received this email in the post this morning, it reads as follows:

Google - Hello,  In the next month, we'll introduce the +1 button and personal recommendations to display ads. The +1 button will begin to appear on AdSense for Content and AdSense for Mobile Content display ad formats -- image, animated gif, and Flash. +1s will be one additional signal to help determine an ad's relevance and we'll continue to show the ads that will generate the most revenue for you.  We previously launched the +1 button on Google search and for publisher sites to make it easier for people to share and discover content across the web. Soon, your users will be able to endorse specific ads and make the ads more likely to appear to their social connections. We believe that these recommendations could help your readers notice ads on your site more, leading to higher returns for you over time.  If you prefer not to show the +1 buttons on display ads on your pages, you can opt out in your account. For more information please visit the Inside AdSense blog.  Sincerely,  The Google AdSense team

So Google is going to let users tell them what Ad’s they like with adding the +1 to them?

It will be interesting to see if it catches on.

Too bad they had to launch it today… It’s seems to be dwarfed by the news of Facebook’s new re-design which is causing a bit of fiasco – no surprise there then.

Solved: Debian Squeeze + Nginx + PHP5-FPM

After tiresomely testing the config – I eventually got it to work.

Once you know how it’s really easy but I kept getting a “502 Bad Gateway” error that confused me.

Benefits of sockets over TCP:

  • Faster connection over sockets than TCP; 20% boost
  • More secure as sockets are harder to break their permissions

Anyway, here’s what you need to do. All config locations are the defaults installed by Debian Squeeze.

Add Dotdeb’s sources in your Debian /etc/apt/source.list

## PHP5-FPM
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

Then install php5-fpm:

apt-get update
apt-get install php5-fpm

Change the settings in /etc/php5/fpm/php-fpm.conf

pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
daemonize = yes
include=/etc/php5/fpm/pool.d/*.conf

Recommended settings in /etc/php5/fpm/pool.d/www.conf

;listen = 127.0.0.1:9000
listen = /var/run/php5-fpm.sock

listen.owner = www-data
listen.group = www-data
listen.mode = 0666

user = www-data
group = www-data

php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[error_reporting] = 0
php_admin_value[memory_limit] = 128M
php_admin_value[date.timezone] = Europe/London

Start/Restart Nginx and PHP5-FPM and voila

/etc/init.d/nginx restart
/etc/init.d/php5-fpm start

Everything should be running smoothly. Enjoy your new faster server!

Thanks to the people below who wrote about it first.

Installing the latest Nginx on Debian Squeeze

I just updated my Nginx on Debian 6 (Squeeze) from 0.7.x.x to 1.0.6 by altering my source list.

Edit your /etc/apt/sources.list to include the following lines:

deb http://nginx.org/packages/debian/ squeeze nginx
deb-src http://nginx.org/packages/debian/ squeeze nginx

Then run `apt-get update` and `apt-get upgrade`.

Follow the on-screen instructions and BOOM! You’re running the latest version of Nginx! My preference is to use Nginx these days instead of Apache2 purely because of the extra performance you gain out of it. Much higher requests per second (rpp).

I highly recommend trying it if you haven’t already.

Facebook change their Applications Policy & Kill FBML

FBML is DEAD, LONG LIVE FBML…

Not surprising news but Facebook has finally retired FBML on 11th March 2011.

What does that mean? Basically it means that you no longer have to use the “Static FBML page” application to create new pages, instead you are now allowed to use iFrames!

*Party poppers and loud cheers!*

Unfortunately, this exciting news turns sour pretty quickly…

With this new ability there are some major roadblocks, mainly for non-tech savy users.

  1. iFrames must be able to serve your own web pages from a web host.
  2. Any pages that you cannot serve with SSL will bring up a user message which will potentially put off visitors, as explained in their blog post about users running Facebook over HTTPS.
  3. Applications. You can only create these iFrame pages with Facebook Applications. For some this will be a real challenge, even as a Web Developer, I still find them difficult.

Making your pages with Facebook Applications

Going back to my previous point. Admins on Facebook will now have to create their own Applications so they can display new pages on their Fan Pages.

There are several difficult hurdles to deal with:

  1. Applications are usually created by Facebook Developers, see http://www.facebook.com/developers
  2. Facebook have changed their Applications policy. You must now register a valid Credit Card or Mobile Number. Paranoid? I am.
  3. Non-tech savy users who innocently created their fan pages will have no idea how to manage their Applications.
  4. Documentation and examples are scarce for developing these new iFrame pages. FBML used to allow you to tap into Facebook services pretty easily but now you have to familiarise yourself with a combination of Signed Requests in PHP and the JavaScript SDK aka the Facebook API.

Basically if you can conquer those requirements, you will be allowed to continue using Facebook pages. In summary, your shopping list should include:

  1. Web Hosting
  2. SSL Hosting to serve your web pages on HTTPS (expensive)
  3. A valid Credit Card or Mobile Number (sorry script kiddies)
  4. A fearless attitude to creating, managing your own Applications and wading through poorly documented examples for endless hours, have fun.
  5. A knowledge of PHP and JavaScript. You prefer a different web language? Tough. Facebook is biased and wants you to use PHP SDK for now.

Hopefully I summed up everything nicely for you. Good luck.

UPDATE: 2nd June 2011
As always, Facebook has quietly made some changes (without really telling anyone).

  • You can use your mobile number to verify yourself as a Facebook Developer, allowing you to add new Applications.
  • Released SDK v3.0.0 which is an upgrade to the last version of SDK v2.2.x
  • Introduce “Facebook Credits” available to all Applications (mostly for games). Virtual currency that Facebook wants you to use. Can use Paypal or Credit Cards to make transactions.

Create your first Twitter App with Zend Framework

I finally got round to writing my first Twitter App using Zend OAuth.

Here are my tips and explanation to getting your Twitter App up and running.

Getting Started

Register at http://dev.twitter.com/ and create your first App. You can change all the settings at any time, so don’t worry about getting them wrong.

Setting Up the Twitter App

Authorise a Domain URL, you can even use localhost for testing purposes.

It is important you set the Callback URL otherwise you can’t use the Browser App option and your OAuth will fail.

Quickly access your App’s details at http://twitter.com/oauth.

When coding with Zend OAuth, read the documentation carefully!
It has everything you need.

My Mistake

I did not understand how to grab the Access Token. Reason? It’s a two part process. Requesting, then Receiving.

The Code

Here is a working example of a Request Token with Zend OAuth and your Twitter App’s Consumer Key and Consumer Secret.

(Note the keys used are the ones from Zend’s Article)

$config = array(
'callbackUrl' => 'http://example.com/callback.php',
'siteUrl' => 'http://twitter.com/oauth',
'consumerKey' => 'gg3DsFTW9OU9eWPnbuPzQ',
'consumerSecret' => 'tFB0fyWLSMf74lkEu9FTyoHXcazOWpbrAjTCCK48A'
);
$consumer = new Zend_Oauth_Consumer($config);

// fetch a request token
$token = $consumer->getRequestToken();

// persist the token to storage
$_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);

// redirect the user
$consumer->redirect();

Steps you must do:

  1. Use the Callback URL to receive the Access Token
  2. Store the Request Token in a $_SESSION
  3. Follow the getAccessToken() example and store this in a $_SESSION or Database (recommended)

Why store the Access Token in a Database?

The best thing about the Access Token is that once you’ve successfully requested one, it never expires!

So save the hassle of requesting a new token and use it throughout your website. Great thing is, it can’t be compromised!

Without the the Consumer Key and Consumer Secret, you can’t hijack the users account for malicious purposes.

Please leave a comment if you want me to write another article about how to implement the example into your scripts or maybe I’ll update this one.

Weekly Round Up: Issue 1

I often hunt around on the internet for the latest information to do with Web Development. Most of the time it goes to my Twitter but I thought it would be great if I could start logging a collection of the best ones I read.

So if you enjoy keeping up with the latest trends, I hope you enjoy my information bites!

HTML5 won’t save the web
http://gizmodo.com/5461711/giz-explains-why-html5-isnt-going-to-save-the-internet

Facebook develop faster PHP
http://www.neowin.net/news/facebook-unveils-hiphop-for-php-039source-code-transformer039

IE8 now “most popular” version of IE
http://www.neowin.net/news/ie8-is-now-the-world039s-most-used-browser

Zend Framework 1.10 Released (and now with versioned documentation!)
http://devzone.zend.com/article/11727-Zend-Framework-1.10.0-STABLE-Released

PHP hates integers (64 bit)
http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/

Google Chrome: Web forms, empty action won’t work!

After doing some testing, I was wondering why the hell my form wasn’t submitting any POST data in Google Chrome.

It turns out that Google Chrome will not “post” to a form when the “action” destination is left blank.

Using a relative path doesn’t seem to work, it has to be absolute… I can understand why they would do this but but it’s the only browser I have come across that behaves in this fashion. Normally other browsers would allow the “action” property to be blank and still allow submission of the form.

It’s good practise but annoying!

What annoys me about Zend Framework

zend_framework_bugI’ve been playing around with the Zend Framework for the last couple of weeks and I love the MVC methods and it’s very well structured and comes with full documentation (very much like CodeIgniter which I’ve used but CI lacked the sustenance for my projects which I desired.)…

So what’s so annoying you may ask?

What bugs me is the naming conventions of methods and functions… as I mentioned, I’ve been trying to get to grips with the framework over the last few weeks but progress is slow. What’s slowing me down? Remembering the naming conventions.

I understand that Zend are trying to create a framework that can be used by a wide range of developers by using verbose names but sometimes I feel they are clunky, unnecessary and hard to remember. Zend’s great for decoupling and using it in anyway you want but it also seems to be it’s own enemy with making simple tasks hard to comprehend.

I find that I am forever creating new classes each time I want to use a Validator or use my Auth functions… I still have a lot to learn, so many of these problems might be solved with a different approach (like extending the classes more). But I’ve yet to find the hidden tricks.

jQuery in WordPress

I am currently in the middle of coding my first plugin for WordPress when I came across my first stumbling block…
Why doesn’t my jQuery code work in the admin area of WordPress??

After some probing on Google, the answer was revealed to me. Basically WordPress doesn’t use “$()” for jQuery, that’s reserved for ProtoType, which is also bundled with WordPress. Instead you have to use “jQuery(‘field’).” in order to get it working.

This article explains it in more detail.

Update:

You can actaully use JQuery normally within WordPress if you just wrap it appropriately.
By default I use this method:

jQuery(function($){
$('<div>').appendTo('body').html('Hello World');
});