Motorcycle Adventures and Free Software

Weblog: Archive

2009-12-01 - 2009-12-31

Easy user location with Midgard

Posted on 2009-12-02 14:08:41 UTC in 60° 9.798 N 24° 55.674 E Helsinki, FI to . 0 comments.

Location is an important context that web services can utilize for fun or smarter user interaction. In past getting location used to be difficult, but now thanks to good IP locationing databases and browser geolocation capabilities it is becoming a lot easier.

But to be really easy, the framework you're using should provide user's location built-in, without you as an application developer having to think about it. This is the reason for Midgard's geolocation features to exist, after all. With Midgard, getting user's location is quite easy:

Midgard MVC (Midgard 9.09)

// Read location from session or user's location log
$user_location = midgardmvc_helper_location_user::get_location();
if (is_null($user_location))
{
    // No location found, try to geocode based on user IP via the GeoPlugin service
    $geocoder = new new midgardmvc_helper_location_geocoder_geoplugin()
    $location_parameters = array('ip' => $_SERVER['REMOTE_ADDR']);
    try
    {
        $user_location = $geocoder->geocode($location_parameters);
        midgardmvc_helper_location_user::set_location($user_location);
    }
    catch (Exception $e)
    {
        // Couldn't get location from IP
    }
}

if (!is_null($user_location))
{
    echo sprintf('You\'re in %s, %s', $user_location->latitude, $user_location->longitude);
    // Will print "You're in 60.1633, 24.9279"
}

MidCOM (Midgard 8.09)

<?php
// Read location from session or user's location log
$user_location = org_routamc_positioning_user::get_location();
if (is_null($user_location))
{
    // No location found, try to geocode based on user IP
    $geocoder = org_routamc_positioning_geocoder::create('geoplugin');
    $location_parameters = array('ip' => $_SERVER['REMOTE_ADDR']);
    $user_location = $geocoder->geocode($location_parameters);
    if (!is_null($user_location))
    {
        // Store geocoded location to session or user's location log
        org_routamc_positioning_user::set_location($user_location);
    }
}

if (!is_null($user_location))
{
    echo sprintf('You\'re in %s, %s', $user_location['latitude'], $user_location['longitude']);
    // Will print "You're in 60.1633, 24.9279"
}
?>

The examples above will work with both anonymous site visitors (using sessions) and registered users (using Midgard's position log). In this example we check if location is already available via browser geolocation or some importer like Qaiku or Fire Eagle, and if not we fall back to IP-based positioning using the GeoPlugin service. The resulting user location array or object (depending on Midgard used) contains a textual description of the place and accuracy information in addition to WGS-84 coordinates.

Sponsored links

Microsoft Certification Exams โนเกีย Nokia มือถือ Online Project Management save money using, phone card
Reviews มือถือ Mobile All Apps

Posting to Qaiku via ping.fm

Posted on 2009-12-07 10:47:02 UTC in 60° 9.798 N 24° 55.674 E Helsinki, FI to . 1 comments.

Ping.fm is a useful tool if you have friends on many social networks as it allows you to write updates to all of them via a single interface. In addition to the web interface there are many tools that allow posting to ping.fm, including SMS and applications for Android handsets and the iPhone.

So far a problem with ping.fm has been that it doesn't support Qaiku, the conversational microblogging tool that we're using to handle workstreaming in Maemo.org Sprints. But now it is possible thanks to the Custom URL functionality on ping.fm.

If you already have a Qaiku account you can start posting to it via ping.fm in the following way:

  1. Enable Qaiku API in your settings and copy the API key
  2. Register to ping.fm
  3. Add a Custom URL to send statuses to
    pingfm-customurl1.png
  4. Enter the URL http://www.qaiku.com/api/statuses/update.json?apikey=xx where xx is your API key as the Custom URL
    pingfm-customurl2.png
  5. Testing posting via the ping.fm web interface:
    pingfm-post.png
  6. See your new post on Qaiku:
    pingfm-qaiku-shown.png
  7. If you want to post to a channel, just begin your message with #channelname

If ping.fm is not your thing, there are also other non-web ways to use Qaiku. For example Mauku for N900 and Gwibber for the Linux desktop work nicely with the service. Qaiku also has an XMPP bot that you can use by simply adding qaiku@jabber.org as your instant messaging contact.

Free Software Foundation Europe in Finland

Posted on 2009-12-11 09:11:13 UTC in 60° 9.798 N 24° 55.674 E Helsinki, FI to . 0 comments.

Free Software Foundation Europe, has recently expanded by the addition of a Finnish country team. FSFE is a non-profit organization dedicated to ensuring software freedom, which is an important building block in an open information society.

The current Finnish team includes Otto Kekäläinen of VALO-CD, the distribution of free software applications for Windows as the country coordinator, and Henri Bergius of Midgard as the deputy coordinator. Timo Jyrinki from Ubuntu Finland is the translation coordinator. Here you can see the team in a recent info event organized together with the Finnish Linux User Group and TKO-äly:

fsfe-finnish-team-2009.png

While COSS is already doing important work for free software in Finland, FSFE amends that agenda by providing focus on the freedom of software and citizen-level participation.

If you're interested in contributing to software freedom, start by joining the Fellowship of the FSFE. You can also contact us at finland@fsfeurope.org and find out more about what is happening in Finland in the field of free software by following the vapaasuomi.fi website.

Midgard in 2009

Posted on 2009-12-31 11:23:35 UTC in 60° 10.572 N 24° 55.206 E Helsinki, FI to . 0 comments.

Vali raising a toast2009 was a pretty active year for the Midgard content repository project, and so it is good to take a look at some of the highlights:

Happy new year to everybody in the Midgard world!

Back