Word Press and Cpanel Password Protected Directories Problem

Ok here is a simple fix for when you add a password protected directory via Cpanel but are using the mod rewrite apache rule for making search engine friendly URLs (permalinks).

For instance having a password protected directory ‘/protected’ will just come up with a 404 not found message on your word press site as it thinks its a permalink.

To fix this just add the following to the top of your .htaccess file that Cpanel generates found inside ‘/protected’ directory

[code]

ErrorDocument 401 default

[/code]

Get YouTube Video Data with PHP

This is amazing simple. I always thought oh no another API and if its anything like Facebooks API then you have to learn something new every month! But this is amazingly easy!

You just need to pull the information you want from You Tube via ‘simplexml‘ in PHP

YouTube has loads of different RSS feeds, in this case I am just using the one that gets all data about a single video.

[php]
//your video id
$v = YOUR_VIDEO_ID

// get xml
$video_feed = file_get_contents("http://gdata.youtube.com/feeds/api/videos/$v");
$sxml = new SimpleXmlElement($video_feed);

//set up nodes
$namespaces = $sxml->getNameSpaces(true);
$media = $sxml->children($namespaces[‘media’]);
$yt = $media->children($namespaces[‘yt’]);
$yt_attrs = $yt->duration->attributes();

//vars
$video_title = $sxml->title;
$video_description = nl2br($sxml->content);
$video_keywords = $media->group->keywords;
$video_length = $yt_attrs[‘seconds’];
[/php]