Monthly Archives: March 2013

How to wrap basic HTTP authentication with PHP

Suppose you have a file hosted on an Apache server that is protected by Basic HTTP Authentication, often via an old-school ‘.htaccess’ file, to prevent anonymous users from downloading it without a valid username/password. Then someone asks you to wrap that protected file download with some kind of GUI, maybe a simple HTML form to gather some standard user data (e.g. name and email address). The trouble is once the user has submitted the form they then get prompted separately by the browser to enter a username/password for the HTTP authentication, and this two step process is a bad user experience and looks unprofessional. What you really want to do is ask the user for the username and password as part of the first form, and then just supply those credentials behind the scenes so the download just starts once the form has been submitted. I was recently asked to solve this exact problem, and there simply wasn’t time to address this properly with a nicer solution.

So here is a simple way to pass in credentials for Basic HTTP Authentication from a PHP download script. You must have the PHP “Client URL Library” (“cURL”) extension installed on the web server hosting the PHP script.

If you just want to download the complete working script, you can get it from my GitHub Gist. If you’d like to read about some of the details, please continue…

Continue reading How to wrap basic HTTP authentication with PHP

How to add Google Authorship to a single author WordPress Blog

Google Authorship is a great new way to boost your online presence by associating your Google+ profile with any web content that you create, so that Google automatically displays your Google+ profile next to any of your content listed in search results. It can help you to attract new followers, and help people to easily find other content that you have produced. Google have also added new “Author Stats” to their Webmaster Tools so that authors can easily see how often their own content is being discovered in Google search results.

This post gives simple instructions on how to add Google Authorship to a WordPress Blog produced by a single author. It assumes that you are using a WordPress Theme that supports WordPress “Menus”, and that you have a menu link to an “About” page about the Blog’s main author.

  1.  Create a Google+ profile that you want to associate with the WordPress Blog in question.
  2. If you don’t already have one, register a suitable email address with the same domain name as the WordPress Blog. Note – it is still possible to associate content from a domain that you don’t have an email address for, but that is not covered by this post.
  3. Activate Google Authorship using your email address with the same domain name as your Blog.
  4. Install the AuthorSure WordPress plugin in your WordPress Blog.
  5. Follow the AuthorSure instructions for configuring a single author Blog.
  6. Ensure that you have added your Google+ profile URL to your WordPress user account profile, since this is where AuthorSure gets the Google+ profile URL from when it automatically inserts the link below every post. When logged in to your WordPress Blog as the admin user, hover over the top-right menu and click on “Edit My Profile”. At the bottom of that profile page in the “Contact Info” section you will find a space for your “Google Plus Profile URL”.
  7. Use the Google Webmaster Structured Data Testing Tool to check if your Blog has been correctly configured for Google Authorship. Paste in an example URL for a post on your Blog to see if it correctly detects your Authorship data.
  8. If this test fails, or you have any other issues, please refer to the Google Authorship help page and double check everything.

In general, it seems to take between several days and several months for your Google+ profile to start appearing next to Google search results for your content, so don’t expect immediate results.