Using Fat Secret Api in Rails 3
I would like to use the Fat S开发者_Go百科ecret API in a Rails 3 application to get nutrition data for an item. I don't need to authenticate any users. I have an development account, with a key and shared secret. However, I don't really understand the OAuth1 authentication. How would I go about accomplishing this? I tried using the 'passport' gem, but got lost.
If all you want is an example of authentication with the API I can help you with that. This API is only OAuth1 so we can use the standard oauth
gem to reduce the boilerplate code that we need to write.
Using the OAuth gem we want to create a consumer and then make a request to the API like so:
@consumer = OAuth::Consumer.new("key", "secret", :site => "http://platform.fatsecret.com/rest/server.api")
@consumer.request(:post, '', token = nil, {:method => "recipe_types.get"})
I wish I could test this but the API signup wont let me test without a URL.
精彩评论