Archive for the ‘Technology’ Category

OAuth, J2ME and FireEagle

Sunday, April 4th, 2010

Recently I have started developing a web app to do some location based stuff.. but I’ll save that for another post. The point here is OAuth, J2ME and FireEagle. I don’t want to loose this information, so I’m posting it here, maybe it will help someone else someday too:

OAuth - Lots of services offer this for communicating with their APIs.

J2ME - Java on my phone. I don’t care for Java much at all and I am not good at it, but I do like the fact that I can write applications for my phone and install them without much hassle.

FireEagle - VERY cool “Location Broker” from Yahoo! I love the idea of being able to report my lat/lon to one place and allow other services to retrieve my location information from there to do what they need to with it. Running several apps on my phone that report my location back to whatever service they come from seems kind of stupid. How about one app to report to fireeagle and everyone else can ask fireeagle where i am instead of requiring me to run their own special app!?

There are a few FireEagle applications for J2ME already, but none are light weight enough for me to run on my phone 24 hours a day, most are mapping applications that happen to do FireEagle updates. I wanted just a simple update to FireEagle every so many minutes and if i traveled at all.. and I was stuck trying to write it myself. To talk to FireEagle’s API I needed to do OAuth in J2ME.. which turned out to be a bigger pain that I had hoped. J2ME is very very stripped down and doesn’t have any of the methods I needed to do any SHA or other encryption very easily without getting too involved with third party libraries.  Luckily FireEagle’s OAuth does let you do OAuth with a “PLAINTEXT” signature - no encryption needed! These OAuth transactions can happen over SSL, so I’m comfortable with it. It took me a while to figure out how to do OAuth with plaintext signatures on my own, and I experimented with it using curl first. Here is how I did OAuth for FireEagle using only curl.. hopefully this eventually leads to someone writing a better J2ME FireEagle updater than I have! :)

You will need the Consumer Key and Consumer Secret from FireEagle before proceeding. For this example I’ll use:

Consumer Key: myConsumerKey

Consumer Secret:  myConsumerSecret

And you’ll need some way to generate a unix timestamp and an “nonce”, which can be just a random string that you will never duplicate. Replace all occurrences of “myTime” and “myNonce” with something appropriate.

STEP 1: Retrieve a Request Token:

Execute:

curl  "https://fireeagle.yahooapis.com/oauth/request_token.json?oauth_consumer_key=myConsumerKey&oauth_version=1.0&oauth_signature_method=PLAINTEXT&oauth_signature=myConsumerSecret%2526&oauth_timestamp=myTime&oauth_callback=oob&oauth_nonce=myNonce

You should receive a response like:

 oauth_token=theOauthToken&oauth_token_secret=theOauthTokenSecret&oauth_callback_confirmed=true

Your J2ME application will present the oauth_token to the user and ask them to enter it at the mobile auth url that you were given at the same time you got your consumer key and secret, probably something like https://fireeagle.yahoo.net/mobile_auth/12345. After your user enters the oauth_token they will be given a verification code, you will need that verification code from the user along with the oauth_token and oauth_token_secret for the next step.

STEP 2: Retrieve a more permanent Access Token that you will store for future use when making FireEagle transactions on behalf of your user.

Execute:

 curl  "https://fireeagle.yahooapis.com/oauth/access_token.xml?oauth_consumer_key=myConsumerKey&oauth_verifier=usersVerificationCode&oauth_token=theOauthToken&oauth_nonce=myNonce&oauth_timestamp=myTime&oauth_signature_method=PLAINTEXT&oauth_version=1.0&oauth_signature=myConsumerSecret%2526theOauthTokenSecret

You should get a response like:

 oauth_token=perminantOauthToken&oauth_token_secret=perminantOauthToeknSecret

You can now store perminantOauthToken and perminantOauthTokenSecret somewhere, you will need them every time you want to do something for this user. You can safely discard of usersVerificationCode and theOauthToken and theOauthTokenSecret from earlier.

Step 3: Do something with the FireEagle API!

For example, if you want to post updated coordinates to FireEagle you can do so with the information you now have without encrypting anything with complex methods that will be difficult to reproduce in a simple J2ME application. Some FireEagle API methods  will require you to make a http POST request, which you can still do with curl for experimentation. Lets say your the coordinates you want to set are:

lon=-77.409813
lat=43.201931

You can update FireEagle with that information by executing:

 curl "oauth_consumer_key=myConsumerKey&oauth_token=perminantOauthToken&lon=-77.409813&lat=43.201931&oauth_nonce=myNonce&oauth_timestamp=myTime&oauth_signature_method=PLAINTEXT&oauth_version=1.0&oauth_signature=myConsumerSecret%2526myPerminantOauthTokenSecret” https://fireeagle.yahooapis.com/api/0.1/update

If all went well you will get something like:


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <user  token="bba6Y0a86WaV" located-at="2010-03-24T05:37:59-07:00"/>
</rsp>
<!-- api1.bh.sp1.yahoo.net  uncompressed/chunked Wed Mar 24 05:37:59 PDT 2010 -->

And that covers it.. with that I was able to write up a crude J2ME FireEagle updater. Hopefully this helps someone someday!

Vacation!

Friday, December 11th, 2009

Its 5:30 and I now have a week off! Since its been a nice long four months since my last post I guess I have some catching up to do.. and will probably miss most of the important stuff, if there was any. If you follow me on Twitter or Facebook this is all stuff you probably already know :)

Family Events: The kids are growing fast! Sawyer is talking about everything AND he plays a few games on the Wii and a racing game on Xbox. I think that he also said his first swear word.. but we are going to try and forget about that. Morgan is even starting to play the Wii and doing a little bit of talking now, she has a few words down pretty good including “Dada”, “Mama”, “Baba”, “Kitty”, “Hot”, “Cold” and “Meow”. I don’t think that the kids are huge Thomas The Train fans, but we have an electronic Thomas train set that we will be buying additional track and cars for to give on Christmas that we all enjoy playing with. OH, AND we found out that our baby due in April will be a BOY!  We are planning to do a home birth again if all continues to go smoothly, the only pain about that (for me anyway) is the insurance company - CIGNA. When Morgan was born in 2008 UnitedHealthcare covered us 100% after only a little back-and-fourth. CIGNA on the other hand is not being as nice about it.. but I think that NY State law is on our side and we will be covered in the end.With the third child on the way we needed to upgrade Kim’s truck to a van - a Kia. So on top of all of our other bills, we now have a more expensive auto-loan to pay for. Oh well.. I’m getting used to the debt and being poor I guess. To add to that, we now have a cat with no name.. exactly what vowed never to get after having to find a new home for our ferrets when Sawyer was born, but sometimes family life isn’t about me and what I believe are the right choices I guess! Seemingly related to all this, but possibly not, I am now on blood pressure medication to try and control my chronic high blood pressure.. something my doctor and I had talked about years ago, but I initially resisted.. but I don’t think that I can put it off any longer. So far it seems to be going well.. we’ll see though.

Other: I’ve been trying to do some “casual” life-logging lately to keep a digital record of things that I would usually forget, but might need to recall someday. I’ve been using a free Evernote account for this, and so far it has been pretty awesome. I can scan in documents, or jot them down with my Livescribe pen and be able to search for text within them from their web gui or my phone! I’ve also tried to tie it together with my social media accounts using Tarpipe, which is another cool site that I would recommend if you use Evernote, Flickr, Twitter, Facebook, Delicious and other such sites. For this vacation I have a pile of tasks that I’ve been trying to keep track of with RememberTheMilk.com.. we’ll see how well it works out as a to-do list over the next 9 days.

Oh yeah, I also tried some J2ME programming for my phone over the last couple months. If anyone is interested I wrote a little app to run in the background while you take pictures with the Samsung Eternity to geoTag your photos. I posted it here.

New Phone!

Monday, July 6th, 2009

Last month I finally upgraded my Sony S710a to a Samsung Eternity (SGH-A867). I had been eying the iPhone for a while, and I know a few people that have one, but there were a couple of things that I just couldn’t get past when picking a new phone. The iPhone is WAY cool for sure, but I don’t use MS Windows at all for anything.. period, and I’m afraid to get the full awesomeness out of the iPhone I would be tied to itunes running on a windows machine. I have an iPod, and use it frequently with gtkpod on my Linux workstation, but the iPhone does soo much more that I think I’d just be missing out. With Apple intentionally making 3rd party interaction with their devices difficult and (at the time) Bluetooth being crippled was enough to make me look at other phones.

So anyway, the Eternity is pretty enough and touchscreeny enough for me to feel like I’m living in 2009 AND bluetooth wasn’t crippled. My requirements for the new phone were: Bluetooth, GPS, run J2ME apps, camera and not be a Windows device. I thought the out-of-the-box Eternity would do all of that.. but unfortunately AT&T restricted the GPS on it. Everything else worked great though! I lived without the GPS for a couple of weeks, and then the good folks at samsung-eternity.com came up with a great hack to get free gps going with 3rd party apps! You can go read all about it here, but in short all you have to do to get Mobile GMaps and amAze GPS going is to use a usb cable to get to your phone with TKFileExplorer (or Bitpim) and remove everything in the exe/java/games/<yourapp>/appdb directory and the exe/java/games/<yourapp>/MANIFEST.MF file. If you are on linux you can try to get Bitpim to do the job, but after trying for a couple hours to get all of its Python dependancies working I gave up and ran TKFileExplorer through wine.. you can read about doing that in my post here.

I’d love to rant about how pissed I was about AT&T locking the GPS to their own stupid nav service, but was unable to keep that level of emotion after finding the above hack. But seriously, I was angry at the world.. do they want people to just buy iPhones that are not as restricted? Why wouldn’t Samsung be upset about this? Oh well.. I’m happy now, and thats all that matters. AT&T can still go to hell though.

Kim’s New Phone

Monday, May 4th, 2009

I have to post about this because I spent more than three hours on it, and for me any non-parenting/husbanding activity that takes more than a few minutes is a significant event. Kim replaced her broken Razor V3 with a Pantech Matrix last week. I’m not that big of a phone geek, BUT I am liking this phone a lot.. mostly because it doesn’t run an MS operating system and it has a real QWERTY keyboard. Its been a while since I’ve looked at any recent phones other than the iphone or G3.. my own phone is approaching old age and the features I thought were cool on it are now pretty much standard. The problem with Kim’s old Razor is that the keypad is busted.. no keys worked on it. The people at Cingular were unable to transfer her contacts or photos to her new phone so I thought that I would give it a try. Here is how I did it.

After compiling USB_ACM into the kernel on my Linux (LFS) machine I was able to use moto4lin to copy her photos off with a usb cable. For anyone else that needs to do this with a Razor, I needed to put it into P2K mode.. the only way I found to do this on this phone was from a terminal do:

AT+MODE=8

From there moto4lin was able to bring up the file list and I copied everything down.

Next step was to get the phone book.. which as it turns out was the most difficult part. Using a terminal again I did a:

AT+MPBR=1,100

to retrieve contacts #1-100. This gave me a list with each row looking something like:

+MPBR: 17,"5855551234",129,"Some Name",3,0,255,0,1,1,255,255,0,"",0,0,"","","","","","","",""

The information I needed was the first few fields: Contact Id, Phone Number, nType, Name, eType. Since she had less than 60 rows, I copied these out and pasted it into a file and wrote a little PHP script to pull out the number, name and eType and put them into the insert format for her new phone. The eTypes are:

0 Work
1 Home
2 Main
3 Mobile
4 Fax
5 Pager
6 Email
7 Mailing list

For her new phone I used Bluetooth to insert the new contacts. To get this working I needed to find the phone ’s address with:

hcitool scan

And then get a /dev device for it with rfcomm. But first I needed to find the modem channel on this phone. To get this I did a:

sdptool browse

And looked for “Dialup Networking”. In the case of the Matrix this is channel 1 so the rfcomm command line was:

rfcomm <ADDRESS> 0 1

The address was the address we found with hcitool, the 0 is the rfcomm device number i’m giving it (will show up as /dev/rfcomm0) and the 1 is the channel. From here I can use minicom or whatever terminal program and do my AT commands to insert. But first I had to set the phonebook to insert to. I couldn’t figure out where to put the phone’s own phonebook entries, so I used the SIM card, which is set with:

AT+CPBS="SM"

I had the PHP script that I mentioned earlier to pull out the name and number spit them out in the preformated GSM phonebook insert commands. Which look like:

AT+CPBW=1,"5855551234",129,"Some Name"

The 1 is the index number, you’ll need to increment this for each entry and the 129 is the non-international phone number.. for me it was the same for every entry and matches what I pulled off of the Razor. Once the numbers were inserted I needed to power cycle the phone to get them to show up. I also wanted the entries to show up with the extra phonebook features offered on this phone (like picture identification and such) so from the phone’s own interface I copied all the SIM phonebook entries onto the phone and then deleted them from the SIM card to avoid duplicates. Seems like everything worked.. one ugly thing about doing this was that the Razor has a separate entry for each number, so a cell number and a home number for “Joe Smith” would be two separate entries in the Razor’s CPBR list, I had my script use the eType to put a (M) or (H) next to the name to signify the type of number it was.

For anyone else interested in doing something similar, you will find more information on the Razor’s AT commands here. And the standard GSM AT commands here.

This was a fun project that I don’t get to do much of anymore.. and I am really liking the Matrix.. and I’m seriously thinking that when the time comes to replace my own (now ancient) phone I’ll go for this instead of an iPhone or G3.. we’ll see though.

OpenID & Verisign VIP

Monday, March 9th, 2009

A while back I purchased a PayPal Security Key, which is a physical key fob that generates a number to use in addition to my normal login. The key fob itself was $5, and I like the idea of having “two-factor” authentication where my money is. A really cool thing that I just found out about today is that the key fob from PayPal is actually a Verisign VIP (Verisign Identity Protection) token.. and can be used everywhere that their own $30 token can be used, including for OpenID authentication at the Verisign Personal Identity Portal! Very cool.

Gmail on my S710a

Tuesday, December 16th, 2008

Today I was playing with Gmail and decided to try their IMAP service with my phone (Sony Ericsson S710a). Google has the imap details listed right on their web page, so I thought it would be straight forward enough. BUT it wasn’t as easy as it sounded. In case I forget, or anyone else is trying to do the same thing, this is what I did to get it working. My phone’s email settings are:

  • Connect Using: Media Net
  • Protocol: IMAP4
  • Incoming Server: imap.gmail.com
  • Incoming Port: 993
  • Encryption:
  •   Incoming Server TLS/SSL, Domain: imap.gmail.com
  •  Outgoing Server: No encryption
  • Mailbox: myusername@gmail.com
  • Password:  mygmailpw
  • Outgoing Mail Server: My own smtp server
  • Outgoing Port: 25
  • Email Address: myemailaddress
  • Download: Headers Only

I also needed to download the appropriate certificates that were not already on my phone and send them over via bluetooth. I found a mention of this in a post here. And the download link is here. I was unable to get google’s smtp server to work, and apparently I am not the only one, so I’m just using my own smtp server elsewhere for outgoing mail.. this seems to be working for me. I’m able to send/receive email from my phone, yay.

Google Streetview

Friday, June 13th, 2008

Yeah! Webster, NY is totally on Google Street View! A friend and I were just poking around on Google Maps trying to track down where a Geocache in Harris Road Cemetery was and saw the blue “street view” roads! But, like other cities.. not all roads are covered.. you can see our circle though, which is pretty exciting to me for some reason.

Soon I’ll be adding Save/Load buttons to The Userbar Designer for subscribers. The Save/Load functionality seems to be working correctly.. the save file are just gzipped XML with the form data from the designer. All I need to do now is setup some sort of Premium Account Manager page to handle user creation and subscription payments. I’ll be using PayPal for payment and instantly activating accounts with IPN (Instant Payment Notification).

Tonight I also installed the Last.FM Pidgin Plugin.. so ‘buddies’ in my contact lists can see what I’m listening to in my status message. Seems to be functioning so far.

Super Bowl Sunday And I Don’t Care

Sunday, February 3rd, 2008

Despite the title of this post, this article will have nothing to do with the super bowl. I just couldn’t think of anything.

Today Kim, Sawyer and I will be going to my mother-in-law’s house to spend the day.. but right now I have time to post because Kim is out shipping with my mom. A little Dustin time is something that I rarely get these days, so I’ll try and make the most of it. This morning I was catching up on some news and read an article about the Social Graph API. Very cool stuff, so I ran and updated a bunch of links to see what will happen.

Last weekend Kim and I painted the living room, downstairs hallway and stairwell a peach beige color, which came out really good! There were a few problem spots above the stairs where I can’t reach, so I’m going to ignore them for now. Next weekend (maybe) we’ll paint the kitchen a “straw hat” color. We’ve been here over four years and the walls really needed a paint job.

I’m also attempting to kill all the snails in our aquarium with some drops I bought from the pet store yesterday. Over the past month or two a few stowaways from the last time we bought fish have reproduced into an infestation. In the beginning we just tried scooping them out with a net and flushing them, but lately it has become clear that we can never keep up with that.

Yesterday evening I went to go see Cloverfield with my friend Mike. I have to say that I think that it was a great movie. I won’t ruin the ending, but I love movies that end that way.

The only other thing that I can think of to post today is that I don’t want to forget how to prepare movies for my ipod nano 3g:

 $ mencoder -oac faac -faacopts br=160 \
   -ovc lavc -lavcopts vcodec=libx264 -vf scale=320:240 \
   -sub "subtitle.srt" \
   input.avi \
   -o output.avi

$ ffmpeg -i output.avi -acodec libfaac -ac 2 output.mov

Oh! And Sawyer is totally getting a haircut this week.. well hopefully.. Kim and I have to stop putting it off.

iPod!

Saturday, December 22nd, 2007

I finally gave in and purchased an iPod… I know, I know… I’m the last person in the world to buy one. BUT I had serious concerns about using one with Linux. For anyone who cares, here is what I’ve done to get my iPod Nano 3G 8GB to be a usable mp3 player with album art on my linux from scratch system. I’m using the current gtkpod and libgpod from svn.

My fstab has this for mounting it as usb storage:

/dev/sdb1 /mnt/ipod vfat gid=506,fmask=0113,dmask=0002,umask=0,users
,iocharset=iso8859-1,codepage=850,noauto,users,exec,suid 0 0

I had a group (gid:506) that has my normal user in it to be able to write to the ipod.

My configure for gtkpod looked like:

$ ./configure --enable-maintainer-mode

My configure for libgpod didn’t have anything special, but i did have to change src/itdb_itunesdb.c because i would get an error every time i saved to the ipod, here is the diff:

Index: itdb_itunesdb.c
 ===================================================================
 --- itdb_itunesdb.c    (revision 1855)
 +++ itdb_itunesdb.c    (working copy)
 @@ -4878,8 +4878,10 @@
fwid = itdb_device_get_firewire_id (fexp->itdb->device);
 if ((fwid == 0) && (itdb_device_requires_checksum (fexp->itdb->device))) {
 +    /*
 g_set_error (error, 0, -1, "Couldn't find the iPod firewire ID");
 return FALSE;
 +    */
 }
if (fexp->wcontents->pos < 0x6c) {

After doing the above i could copy music to the ipod and see that space was being used up but songs would not show up on the ipod’s interface until I changed the SysInfo file as described here.

For the album art i use AlbumArt-QT to fetch covers from various web sites. I just got all this working like a few hours ago, but so far i haven’t run into any trouble!

Almost Christmas Time

Friday, December 14th, 2007

The other day Kim, Sawyer and I setup our (fake) Christmas tree. I personally am an athiest but I’m all about the holiday anyway. The year needs a few breaks for well wishing and gift giving.. and I kind of like the holiday specials on TV and Christmasy music at the mall. I also can’t wait for Saywer to get all excited abut the holidays. Here he is with his first Christmas tree:

Sawyer and Mommy

Today I also decided to try out Twitter. So far it seems like a pretty cool idea, I set it up so that I can post to it from Jabber and my cell phone.