2011-08-15 64 views

回答

0

如果你想要的只是API验证的一个例子,我可以帮你解决这个问题。此API仅为OAuth1,因此我们可以使用标准的oauth gem来减少我们需要编写的样板代码。

使用我们要像这样创造一个消费者,然后让该API的请求的OAuth宝石:

@consumer = OAuth::Consumer.new("key", "secret", :site => "http://platform.fatsecret.com/rest/server.api") 
@consumer.request(:post, '', token = nil, {:method => "recipe_types.get"}) 

我希望我能考这个,但是API申请不会让我测试没有一个URL。

+0

这没有奏效,它返回'Missing required oauth parameter:oauth_signature_method'。但是,http://groups.google.com/group/fatsecret-platform-api/browse_thread/thread/45b3e8efa412c660/c45159103b1dcd94?lnk=gst&q=rails#c45159103b1dcd94上的代码有效。不过,我会喜欢更简洁的版本。感谢您的帮助。 – V9801