Archive for php

Adding Flickr photos to Foursquare using YQL

Foursquare

Image by miss604 via Flickr

Browsing the updated Foursquare development documents I came across a real nice hidden gem: it appears that the Flickr folks have enabled so called machine tags to associate a photo with a Foursquare venue.

The almost hidden quote from the Flickr Developer blog:

This is the part where I casually mention that we’ve also added machine tags extra love for Four Square venues IDs. I’m just saying…

Now how cool would it be to display a little photo on my Foursquare Layar venue detail pages?
Remembering @codepo8‘s execellent talk at the Fronteers conference last week, I realized that this is where the really cool YQL engine comes in really handy.

And indeed, the following query does it all:

select * from flickr.photos.search
    where machine_tags="foursquare:venue=132009"
    limit 1

Just save the REST command url, wrap it in a little PHP handler and we’re good to go (homework for next time: process the YQL response in XML format with js/e4x and skip the PHP part altogether).

So now you will see a little thumbnail picture for every venue which has a photo tagged on Flickr. There aren’t many yet, but hey, it’s a start!

See it in action in the Foursquare Layar app on your phone (iPhone, Android) or read my announcement for more background information about the foursquare layar app.

Reblog this post [with Zemanta]

Popularity: 5%

Post to Twitter Tweet This Post to Delicious Delicious Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

Tags: , , , , ,
Comments off

Choice of PHP Frameworks

PHP

Image via Wikipedia

As of today there is a Tweet Poll running with the question: Which PHP opensource framework do you mostly use?
An interesting question because the market of PHP frameworks appears pretty fragmented after 750+ votes are cast. Leading is Zend Framework (does this qualify as Open Source?), followed by Symfony, Cake PHP, CodeIgniter, all around 10%. There are also a few stray ones: I don’t consider PEAR a framework and the choice “my own” can be disputed as well.

For now there is no clear winner, something I already had that gut feeling about. Wonder where this is going to stabilize (and of course, how representative the twitter votes are anyway). See for yourself, the embedded graph below should stay up to date and you may cast your vote if you ike.

Reblog this post [with Zemanta]

Popularity: 6%

Post to Twitter Tweet This Post to Delicious Delicious Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

Tags: , , , , , ,
Comments off

Use your blog as shortened URL service

WordTwit 2.0
Image by Duane Storey via Flickr

I just discovered and installed a very nice WordPress plugin, WordTwit. The main purpose of this plugin is to tweet your new blog posts on Twitter, together with a link to the new blog post.

So far nothing too shocking new, but the latest version (2.0.x) of the plugin adds the option to use your own blog as url shortening and redirecting service. Think tinyurl.com, is.gd or one of the gazillion alternatives out there.

Now that is really cool. Except it didn’t work for me.

Turns out that there was a little bug if your blog is not served off the root or your domain, but a sub directory instead (which is /blog in my case).

So, a patch (shortened link, noticed?) solved this and all should be set to go now.

Oh and this post is serving as a test post for the Twitter update…

Reblog this post [with Zemanta]

Popularity: 6%

Post to Twitter Tweet This Post to Delicious Delicious Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

Tags: , , , , ,
Comments off

Fix for error in WordPress rss feed module

WordPress Pumpkin

Image by Eric M Martin via Flickr

Using WordPress 2.7.1, there is a problem with the Atom feed export.

In the apache error log are many occurrences of these two lines:

Bad arguments. in /var/www/.../wp-includes/rss.php on line 175,
The first argument, 'map_attrs', should be either NULL or a valid callback

The problem appears to be a simple coding error: the callback function should be called as array reference, array(object, user_func).

This has been reported as issue #9225, read on if you want to fix it for yourself right away…

Read the rest of this entry »

Popularity: 27%

Post to Twitter Tweet This Post to Delicious Delicious Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

Tags: , , , ,
Comments off

WordPress config & database charset

Image representing WordPress as depicted in Cr...

Image via CrunchBase

As part of upgrading to WordPress 2.7, the character encoding of some existing posts appeared suddenly broken.

Turns out that the charset specification from wp-config.php was not interpreted correctly any longer as UTF-8; changing the name from ‘utf8‘ (without dash) to ‘utf-8‘ did the trick.

Update Feb 24: my error log shows lots and lots of warnings like these:

WordPress database error Unknown character set: 'utf-8' for
  query SET NAMES 'utf-8' made by require, require_once,
  require_once, require_once, require_wp_db, require_once

The right solution seems to remove (comment) the line specifying the DB_CHARSET alltogether:

/** Database Charset to use in creating database tables. */
// define('DB_CHARSET', 'utf8');

Read more about editing wp-config (wordpress.org)…

Reblog this post [with Zemanta]

Popularity: 28%

Post to Twitter Tweet This Post to Delicious Delicious Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

Tags: , , , , , ,
Comments (1)

Using pagination with CakePHP’s finderQuery SQL

Cakephp 1.2

Update February 2009: this article is now about a year old and deals with an early beta versions of CakePHP 1.2. In the mean time, CakePHP 1.2 has been released with many improvements and great documentation. Please don’t use this patch, use this instead. I’ll leave the article below for reference.

Cakephp lets you define various kinds of associations between models. The principle is really simple, just define arrays like $hasMany in your main model, where associations with other models are defined.

For most purposes this does the trick, most associations are made by convention, but you can override these as well for e.g. database (foreign-) keys.

From there on, you can use all cake built-in functionality to retrieve model data. One such feature is auto pagination, where the page size is set through the value of the limit field in the model’s definition.

If you’re crafting something really complex, you can define your own SQL query in the finderQuery field. This is very nice, but the trade-of is that the other fields are ignored in the query. And if fields limit and offset are ignored, you no longer get auto pagination.

The patch below fixes this for the current development tree of CakePHP 1.2 (revision 6461).
Read the rest of this entry »

Popularity: 82%

Post to Twitter Tweet This Post to Delicious Delicious Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

Tags: , , , , , ,
Comments off

« Previous entries Next Page » Next Page »

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.