« How to Set Up Google GPS Tracking on your Palm Pre!
How to Make Your Palm Pre’s Battery Last Longer! »

How to Tweet Palm Pre’s GPS Location to Your Twitter!

by admin on Sunday, August 23rd, 2009
33 Comments »
ReTweet This!

(Download This YouTube Video using FREE FLVDirect software)

spacer

(Screenshot of @trackmypalmpre, which gets updated with location of my Palm Pre every hour.)

As promised on my last blog post on how to set up Google GPS tracking on your Palm Pre, I will now show you how to “tweet’ your GPS location to a Twitter account so you can track it on Twitter too.

This might be a great way to keep “track” of where your Palm Pre has been.  You could probably even make a GoogleMaps using the Twitter RSS feed to show exactly where your Palm Pre has been traveling in the past.

The steps should be very similar to the Google GPS tracking code except with some CURL commands added to PHP code so first, do the steps mentioned in the previous post if you haven’t:

First, you will have to setup SSH and dynamic DNS on your phone so you can setup a simple HTML page that will show you the exact location of your Palm Pre via Google Maps.

Next, do steps 1, steps 5 through 8 on my previous post on how to install/run a WordPress blog on your Palm Pre.  These steps will install Lighttpd, which is basically needed for serving web pages on your Palm Pre.  Since you don’t need MySQL database, you can skip the other  steps.

Now, browse to your web root directory typing the cd command below:

cd /opt/share/www/

Next, use the following command to enable writing on your Palm Pre linux filesystem:

sudo mount -o remount,rw /

Next, let’s create a new file called tweet.php by typing the command below:

sudo vi tweet.php

We are almost done, simply copy and paste the code below by hitting “i” and Shift-Ins inside the VI editor:

<?php
$gps = `luna-send -n 1 palm://com.palm.location/getCurrentPosition {} 2>&1 | cut -d, -f4,5 | sed -r ‘s/[^-\.0-9,]//g’`;

exec(‘curl –basic –user mytwitterid:mytwitterpassword –data status=”‘.$gps.’” twitter.com/statuses/update.xml’);
echo $gps;

?>

Make sure to replace mytwitterid and mytwitterpassword with your Twitter id and password.

Open up the new tweet.php file on  your computer’s browser like thi where my.blogdns.com is the dynamic DNS you setup earlier.

my.blogdns.com:9999/tweet.php

You should see a screenshot similar to something below:

spacer

Now open your Twitter account, you should see your status update like this:
(If it does look something like below, congrats!  You just learned how to “tweet” your Palm Pre’s GPS location via Twitter API!)

spacer

Next, we will need to set up a cron job so your GPS location gets updated every hour.

Let’s first turn the Palm’s default cron job on, which is off by default by editing the file /etc/event.d/crond:
(Thanks to this Cron guide, it took me over 10 hours to get the Cron working but this method works!)

sudo vi /etc/event.d/mod-crond

Add the following lines to the beginning of the file by copying and pasting it using key “i” and Shift+Ins:

# -*- mode: conf; -*-

# jobfile for busybox crond, with pre-start commands to create the
# directory and files it wants by default.  That there's not 'start
# on' stanza is intentional: it's for development use only.  We can
# turn it on later if we need it, e.g. to keep the clock synced.  It
# does work.

start on stopped configure
stop on started start_update

respawn

exec /usr/sbin/crond -f -L /var/log/crond

pre-start script
    mkdir -p /var/spool/cron/crontabs
    ln -sf /etc/cron/crontabs/root /var/spool/cron/crontabs/root
end script

Make the cron.d directory:

sudo mkdir -p  /etc/cron/crontabs

Create a new cron job file:

sudo vi /etc/cron/crontabs/root

Press “i” and copy and paste the following code with Shift+Ins:

0 * * * * /opt/bin/php /opt/share/www/tweet.php

This will “tweet” your GPS location every 0 min of the hour. For testing you can change 0 to */1 to tweet every minute.

We will need to start the cron job to start taking effect so let’s start the cron with the following command:
(You don’t  need to do this again as above script mod-cron will automatically start the cron job next time your Palm Pre re-boots.)

sudo -i initctl start crond

You should now be able to see your Twitter account being updated with your Palm Pre’s GPS location every hour.  Congratulations, you did it! spacer

You can check out the status of my GPS twitter account here @trackmypalmpre which gets updated every hour.

Final Words

I have to say there so much more you can do with Palm Pre, GPS, and Twitter so I will leave it up to you to make your next project.  (and don’t forget to let me know about it by e-mailing me at palm [at] palmpre-hacks.com!)

I think this simple code should open up a slew of opportunities for you to hack it for any other Twitter apps you want to make with the Palm Pre.

The advantage of “tweeting” your GPS location versus seeing the GoogleMaps GPS location might be that you can keep a history of where your Palm Pre has been using free servicess like Twitter.  I am sure you can even make an app where you can map out your travels with the Palm Pre using Twitter RSS feed.  (maybe that will be my next application)

Update: I’ve been getting a lot of negative comments WHY you need this.  I will say this, “it can  save your life if you get lost in the snow.”  And it would have saved James Kim’s life. (RIP)

Also a great way to keep track of where your kids and girlfriends have been.  Simply set the Twitter account to “private” and only YOU can see the updates.

Thanks again to WebOS-Internals as I’ve used it to make this DIY possible!

Have fun hacking the Palm Pre! spacer

Free Nexus One phones



Enter your zip code here and find out if you can qualify for 2 free Nexus One phones.

Rate

spacer spacer spacer spacer spacer (4 votes, average: 5.00 out of 5)
spacer  Loading ...

Tags: gps, gps location, hack, palm pre, tweet, twiter
Categories: Featured, Palm Pre Hacks.

Related News and Resources

spacer
How to Set Up Google GPS Tracking on your Palm Pre!
spacer
How to Install/Run A WordPress Blog on a Palm Pre!
spacer
How to SSH into Your Palm Pre!
spacer
How To Hack(Tether) Palm Pre into a WiFi Router!


33 Responses to “How to Tweet Palm Pre’s GPS Location to Your Twitter!”

  1. Palm Pre GPS Tweets - Hack a Day Says:
    August 25th, 2009 at 4:02 pm

    [...] sent in this project he’s been working on. He has posted instructions on how to get your Palm Pre to tweet its GPS coordinates at regular intervals. It does require that you have Linux installed on your Pre, but that’s [...]

  2. spacer Andrew Batchelor Says:
    August 25th, 2009 at 11:53 am

    Will Zerointracking.com work on a Palm Pre?

  3. Palm Pre GPS Tweets | Diy all the Way Says:
    August 25th, 2009 at 6:03 pm

    [...] sent in this project he’s been working on. He has posted instructions on how to get your Palm Pre to tweet its GPS coordinates at regular intervals. It does require that you have Linux installed on your Pre, but that’s [...]

  4. Palm Pre tweets GPS coordinates » GPS NEWS and REVIEW Says:
    August 27th, 2009 at 9:56 am

    [...] What? You can write shorter regular expression that does the same thing? Well… here are the rest of the instructions. [...]

  5. Palm Pre tweets GPS coordinates - Gadget Reviews Says:
    August 27th, 2009 at 12:25 pm

    [...] What? You can write shorter regular expression that does the same thing? Well… here are the rest of the instructions. [...]

  6. Palm Pre tweets your location | Gadgets 411 Says:
    August 28th, 2009 at 4:42 am

    [...] directions are available here, but do exercise caution when doing [...]

  7. Palm Pre tweets your location | Fortysixty’s Gadget Blog Says:
    August 28th, 2009 at 4:49 am

    [...] directions are available here, but do exercise caution when doing [...]

  8. Palm Pre tweets your location | Boolean Technology BLOG Says:
    August 28th, 2009 at 4:59 am

    [...] instructions are available here, but do exercise caution when doing [...]

  9. Palm Pre tweets your location | Gadget News Says:
    August 28th, 2009 at 9:58 am

    [...] directions are available here, but do exercise caution when doing [...]

  10. Palm Pre tweets your location | Apple Iphone and Tech News Says:
    August 28th, 2009 at 10:27 am

    [...] directions are available here, but do exercise caution when doing [...]

  11. Palm Pre tweets your location | Geek Land Says:
    August 28th, 2009 at 11:30 am

    [...] instructions are available here, but do exercise caution when doing [...]

  12. Have Your Palm Pre Automatically Twitter Your Current Location | Fun in Box !!! Says:
    September 1st, 2009 at 6:35 am

    [...] PalmPreHacks ] VIA [ UberGizmo [...]

  13. hypes are us » Blog Archive » Hack: Mit Palm Pre automatisch GPS-Position twittern Says:
    September 1st, 2009 at 5:33 pm

    [...] Read | Permalink | Email this | Comments [...]

  14. Palm Pre tweets your location | Gizmo News Says:
    September 2nd, 2009 at 2:33 pm

    [...] directions are available here, but do exercise caution when doing [...]

  15. spacer wtgreen Says:
    September 3rd, 2009 at 12:41 pm

    I've never used Twitter, but can you twitter an url? Why not twitter the Google Maps url to the GPS coordinates, then you can simply click the links on the twitter page to see where the phone has been vs. having to manually do something with the GPS coords.

  16. spacer zedomax Says:
    September 3rd, 2009 at 11:29 pm

    Yes you can twitter the URL too, you need it? I can make it in about 15 min.

  17. spacer wtgreen Says:
    September 4th, 2009 at 10:33 am

    Twittering the URL just seems like the logical extension of the two GPS tracking methods shown. If you're going to go to the Twitter page to see the coordinates, or if you're going to subscribe to the twitter feed, the next thing you'd want is to know where those coords are on a map. Twittering the Google Maps URL with the coords embedded makes it simple and immediately more useful.

    Of course, capturing the twitter feed coords over time, storing them and then bringing them all up on a map later would be the most clever of all, but that's much more involved.

    I'm going to try this out this weekend. If you're volunteering to demonstrate the change required to twitter the Google Maps url, I'll gladly take you up on it. I'm sure you'll be faster than me, and I imagine it'll be useful to other people who decide to try this too.

  18. spacer wtgreen Says:
    September 5th, 2009 at 10:30 am

    A couple more comments…

    First, thanks for posting this. It's a cool hack and very useful.

    Second, I ran into a problem with pasting the tweet.php commands. I cut-and-pasted from Firefox into my putty session, but many of the characters – the -,', and ” chars) didn't paste in properly. I didn't notice this at first and so when things weren't working it took me a while to track down the problem.

    Finally, if you're doing this from home and your phone is connected to your wireless network, your phone is likely inaccessible from the internet and trying to directly access your phone's web server will fail, and thus the step above that checks your tweet output via the browser might not work. Of course you can substitute your local ip address on your network, or port-forward and all that stuff, but just in case someone else runs into trouble, I thought I'd mention it.

  19. spacer wtgreen Says:
    September 5th, 2009 at 10:49 am

    Finally, I hope, there's a bug in the exec( curl ) line of tweet.php above.

    It should read: exec('curl –basic –user mytwitterid:mytwitterpassword –data “status='.$gps.' ” twitter.com/statuses/update.xml&#39 spacer ;

    The difference here is the double-dashes on the named parameters and the double-quote being in front of the word “status” instead of following the equal sign. Without these changes the status won't update.

  20. Palm Pre hack reports your location to Twitter | GPS Obsessed Says:
    September 5th, 2009 at 5:47 pm

    [...] tracks your location via the Palm Pre smartphone, why not begin tracking yourself as well.  Palm Pre Hacks has put together a way for you to track your location through your Pre and then report your [...]

  21. Envoyez votre position GPS sur Twitter - webOS-France - Forums Says:
    September 7th, 2009 at 9:16 pm

    [...] du fonctionnement de ce hack. Retrouvez comment faire fonctionner ce hack sur votre Pre ici : How to Tweet Palm Pre’s GPS Location to Your Twitter! | Palm Pre Hacks Blog! __________________ Flux RSS / [...]

  22. spacer Rp Says:
    September 10th, 2009 at 10:28 pm

    <?php
    $gps=`luna-send -n 1 palm://com.palm.location/getCurrentPosition {} 2>&1 | cut -d, -f4,5 | sed -r 's/[^-.0-9,]//g'`;
    $gtext='maps.google.com/?f=q%26iwloc=%26addr%26hl=en%26t=h%26q=';
    $btext=$gtext.$gps;
    exec('curl –basic –user xxx:xxx –data “status='.$btext.'” twitter.com/statuses/update.xml&#39 spacer ;
    echo $gps;
    echo $gtext;
    echo $btext;
    ?>
    Getting close… spacer

    But this gives me this which I don't get at all…

    bit.ly/cJKyH ,-95.68478107452393 The comma is messing it up I guess? All pretty new to me… spacer

  23. Twitter Hack – How to Tweet Your Palm Pre’s GPS Location! | TweetHacking.com – Twitter Hacks Says:
    September 11th, 2009 at 9:52 pm

    [...] a really fun Twitter hack that shows you how to “tweet” your Palm Pre’s GPS location to your Twitter account.  This could be a great way to track your Pre’s whereabouts as you can also optionally set [...]

  24. spacer wtgreen Says:
    September 12th, 2009 at 12:08 pm

    I was getting something quite similar. I think the bit.ly reference is simply twitter changing the long url to a shorter one that doesn't exceed the twitter 160 char length. Bit.ly is just like the tinyurl.com service. Unfortunately it appears that Twitter thinks the URL ends at the comma in the GPS coords and doesn't encode the entire URL, so it ends up broken. I tried encoding the commas using the hex %2C but that didn't help. I'm not sure if it's just me not knowing enough about URL encoding or Twitter just being flawed in it's URL shortening. I suspect it's just me not knowing how to do it.

  25. spacer VicNaz1 Says:
    September 21st, 2009 at 3:21 pm

    Hi, I would very much like to speak with whoever got the Palm Pre to automatically send GPS coordinates via SMS. I am trying to find an automatic Search and Rescue tool for use in small private airplanes. I have checked with the FCC (and FAA) and cell phones are legal on General Aviation airplanes as long as they avoid the 800 MHz frequency range. Also, Radar coverage for small airplanes just doesn't do the trick so a periodic SMS message with GPS info would be steller. Please contact me if you can. I'm willing to travel or whatever to get this to work.

    Thanks,
    Victor Nazarian victor.nazarian@auatac.com

  26. spacer gavin Says:
    November 18th, 2009 at 7:00 pm

    Thank you very very much!

  27. spacer gavinengel Says:
    November 18th, 2009 at 10:08 pm

    Hi there, a question. I managed to overwrite everything in the file: /etc/event.d/mod-crond
    When I was prepending a bit to it. What should be in the file when all is said and done? thank you.

  28. spacer gavinengel Says:
    November 19th, 2009 at 1:01 am

    Another question please. I have the crontab calling a small php script, which wget's a page on my server with latitude and longitude. My server saves this information with a timestamp, so I can do maps later on.

    So, here is my question: The cron only seems to work when I am actively using my Pre. Is there a way to make the cron run (and call my script) 24/7?

  29. Как Чирикать Пальма Pre’s GPS Местоположение к Твоему Щебету! » SEO блог о поисковых машинах. Says:
    January 18th, 2010 at 10:26 am

    [...] местоположение твоей Пальмы Пред через Карты Google. How to Tweet Palm Pre’s GPS Location to Your Twitter! Затем, сделай шаги 1, шаги 5 – 8 на моей предыдущей почте [...]

  30. spacer Palm pre batteries Says:
    February 10th, 2010 at 5:41 am

    You could use your Palm Pre as a GPS tracking system via Twitter so people can find you if you get lost in the snow. remember that CNet guy who got snowed in? He’d be alive today if he had this phone with him.

  31. spacer tweet adder coupon code Says:
    April 2nd, 2010 at 2:05 pm

    If you’re able to get more Twitter followers, then you are in a very great position to use the Twitter marketing to get more traffic and buyers.|Automation is a required way for you to be effective to talk to your Followers without having to be at your computer the whole day. 

  32. spacer Jomaame Says:
    April 22nd, 2010 at 8:28 am

    The luna string works perfectly but your twitter command didn’t work at all. At least it didn’t work for me. I tinkered around and came up with something that does work and here it is.

    $username = ‘your twitter username’
    ##Keep the single quotes when you enter the variable for username and password
    $password = ‘your twitter password’

    $g = `luna-send -n 1 palm://com.palm.location/getCurrentPosition {} 2>&1 | cut -d, -f4,5 | sed -r ‘s/[^-\.0-9,]//g’`;

    $result = shell_exec(‘curl twitter.com/statuses/update.xml -u ‘.$username.’:’.$password.’ -d status=”‘.str_replace(‘”‘,’\”‘,$g).’”‘);

    echo $result;

  33. spacer matt Says:
    December 19th, 2010 at 10:09 pm

    Does this code still work. This is what I have exactly and it wont work. Am i missing something? I really need this just to work for adding comments on my twitter through my website.

    When i execute the following code it just says Test cron tweet in my browser and it won’t show it on my twitter account.

Leave a Reply