Posts Tagged ‘PHP’

 

 

March 11th, 2010
C

PHP Viddler API Client – Forked

Okay that title sounds either a bit naughty or nasty, it’s neither. I forked the official PHP Viddler API wrapper and wrote a new one. Why? Well because when I worked there I wrote smaller client which worked out well for me so I’ve decided to release it.

If you strip out the comments from the new client, it’s less than 200 lines of code. Now I just focused on the core API, I didn’t add any of the add-on methods for embeds, oembed, etc. If you are looking for those I would suggest using the original Viddler client. I wanted to keep this lightweight, I may add it later on as an extension so if you want to use it you can, but for now, just keeping it simple.

So how did I strip so much out of the original? I used no 3rd party classes. I used only what is in PHP. I ditched the xmlparser.php file and went with SimpleXML. I also didn’t write a method for every for every possible API method. Actually I didn’t write one for any of them. I took advantage of PHP’s magic method __call(). Which is automatically called when the user calls an object method that doesn’t exist.

$viddler = new Viddler('API KEY');
$res = $viddler->user_auth(array(
  'user'      =>  'USERNAME'
  'password'  =>  'YOUR PASS'
));

CONTINUE READING | TWEET THIS | COMMENT (1)

March 5th, 2010
C

Simple Tag Bar for WordPress

So when I did the little redesign of my site earlier this week I added a right rail. With that I wanted to add some way to show tags that was not a tag cloud and wasn’t just a list of tags. I noticed on a co-worker’s blog (Kyle Slattery) that he had a really nice tag display. So I stole it, er better yet re-purposed it. The way Kyle did it reminded me of how Django makes its graphs, very clean and crisp. I really liked the idea and the presentation.

He doesn’t use WordPress so I had to build a quick script to accomplish this in WordPress. Easy enough actually. What it does it grab your top ten tags then do a little math to display them in a graph format. The more times a tag was used, the larger the graph. Again pretty simple.

CONTINUE READING | TWEET THIS | COMMENT (3)