Can I get the Instagram access_token in a rails rake task?
===

I would like to use the Instagram gem in a rake task that runs once a day to get the latest posts of a particular hash tag. 

In looking at the documentation of the Instagram API you need an access_token to do just about anything meaningful. 

The documentation gives an example of using "curl" to get an access_token and I'm wondering how I would translate that example into ruby so if my rails app doesn't have a toke already I can get one this way.

Here is the curl example giving on the following page of the Instagram API

        curl \-F 'client_id=CLIENT-ID' \
        -F 'client_secret=CLIENT-SECRET' \
        -F 'grant_type=authorization_code' \
        -F 'redirect_uri=YOUR-REDIRECT-URI' \
        -F 'code=CODE' \https://api.instagram.com/oauth/access_token

    If successful, this call will return a neatly packaged OAuth Token that you can use to make authenticated calls to the API. We also include the user who just authenticated for your convenience:
    
    {
        "access_token": "fb2e77d.47a0479900504cb3ab4a1f626d174d2d",
        "user": {
            "id": "1574083",
            "username": "snoopdogg",
            "full_name": "Snoop Dogg",
            "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg"
        }
    }

I was thinking I could use something like URI.parse() and then open() on the uri but that doesn't seem to do the trick. I get a 404 when trying that.