iPhone + FireEagle + Facebook

wo, 26/11/2008 - 11:18 -- robbie

A little over a month ago we couldn't find any iPhone application that enabled us to share our location with the rest of the world automatically. A few hours later we had our iPhone location shared on Facebook through FireEagle. Our steps:

  1. Locating the iPhone (3G)
  2. Sending our location to FireEagle
  3. Aggregating FireEagle on Facebook

1. Locating the iPhone (3G)

Jailbreak your iPhone
There are a bunch of iPhone applications available that update your location, even to FireEagle, but not automatically, running in the background. The iPhone in general doesn't let you run applications in the background. For this to work, you'll first have to unlock jailbreak your iPhone 3G. There is a bunch of information on how to do this online, many use the QuickPWN tool.

Install Locatable
Now, let's look at some available software that we can extend in stead of reinventing the wheel. After unlocking your iPhone you have the Cydia application installed which acts as an App Store that provides free unofficial iPhone applications. One of them is called Locatable. Install it. While it doesn't provide the ability to directly upload to FireEagle (yet?) out of the box, it does provide us an interesting deamon executable we can use. (I guess you could also use Erica Sadun's findme application with a few tweaks).

For the next steps you'll have to install the OpenSSH package through Cydia and need some SSH experience. For users with lesser experience, read this short article about it.

Install the locatemestart and locateme script, sqlite3 and the location db
Download the locatemestart and the locateme script and put them in /var/root/bin. Make them executable with the next command:

~/bin root# chmod u+x locatemestart
~/bin root# chmod u+x locateme

Also install the SQLite v3 package through Cydia. We use this to store our location in a local database. The database itself can be found here. Download it and put it (also) in /var/root/bin.

Change/Add the .plist file
A jailbreaked iPhone allows you to run applications in the background through launchd which you can control using launchctl. Create a new, or change the already available .plist file at /System/Library/LaunchDaemons/com.tralfamadore.locatable.plist into:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
           <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <false/>
    </dict>
        <key>RunAtLoad</key>
        <true/>
    <key>StartInterval</key>
    <integer>300</integer>
    <key>Label</key>
    <string>com.tralfamadore.locatable</string>
    <key>ProgramArguments</key>
    <array>
    <string>/var/root/bin/locatemestart</string>
    </array>
        <key>Nice</key>
        <integer>20</integer>
</dict>
</plist>

 If however you create a new file be sure to disable the old one because we will be using the /usr/libexec/relocatable/Relocatable and only one instance of it can be running. While Locatable itselfs runs it as background process, any other call to it (e.g. from the /var/root/bin/locatemestart script) will fail.

Reload the .plist file

Reload the .plist file using following commands:

~/bin root# launchctl unload /System/Library/LaunchDaemons/com.tralfamadore.locatable.plist
~/bin root# launchctl load /System/Library/LaunchDaemons/com.tralfamadore.locatable.plist


Ready for the next step
At this moment, if you reboot your iPhone (or use launchctl to reload your .plist file), your location will be stored in the location.db. You can check this with the following command:

~/bin root# sqlite3 location.db "select * from locations limit 50"

If a location is returned, you are ready for the next step. Otherwise, there are a few log files in the /var/root/bin directory you can use for debugging your troubles.

2. Sending our location to FireEagle

Install Python, request a FireEagle key, and install the FireEagle script
- Install the Python package through Cydia.
- Request a FireEagle API key for Mobile applications by following this link.
- Over at the Yahoo FireEagle site there is some sample code written in Python that calls the FireEagle API's. We changed a few rules, download our better_walkthru.py version and put it again in the /var/root/bin directory.
- We will also need the Python OAuth library from http://oauth.net/code which can be found here.
- Alter our better_walkthru.py file and change these lines:

# key and secret you got from Fire Eagle when registering an application
CONSUMER_KEY = 'CHANGEME' # consumer key for your app
CONSUMER_SECRET = 'CHANGEMETOO' # consumer secret for your app

- Execute the script once by typing:

~/bin root# python better_walkthru.py

and follow instructions. You'll have to navigate to a specific URL to authorize this application to FireEagle.

Get your iPhone online, CONTINUALLY
You still need some iPhone settings before it updates continually. We do this through Settings > Fetch new data where you can choose your interval your location should be updated. We strongly advise you NOT to enable Push. It will drain your battery in a whip. A good setting is half an hour. You might need to first configure a mail/exchange account (can anyone confirm?).

Once this step is completed, your iPhone should be sending it's location to FireEagle automatically. Check this through the My Location link at the FireEagle site.

3. Aggregating FireEagle on Facebook

Now, for the last and final step, we created a little Facebook application. Navigate to http://www.concept3.be/fireeagle, install the application and follow the instructions. You'll then be able to add FireEagle to your profile:

Et voila!

 

Reacties

Reactie toevoegen