.NET 4 上的REST 框架 介紹了.NET/Mono 上幾個RESTful方面的工具庫,在Rest 客戶端庫之前介紹過了RestSharp《使用RestSharp 庫消費Restful Service》,今天介紹一個新的庫Hammock ,Hammock是個免費開源的框架,托管在github上https://github.com/danielcrenna/hammock, 對網絡操作進行了很好的封裝,包含OAuth,支持異步操作,查詢緩存、mocking、rate limiting 等等。tweetsharp(https://github.com/danielcrenna/tweetsharp)中也用到了它。新浪微博的一個第三方SDKhttp://code.google.com/p/weibo4sharp/ 也使用了這個庫,這個庫和Restsharp相比都有異曲同工之妙,使用方法都差不多。
使用步驟如下:
1,實例化RestClient對象
2,設置該對象的一些屬性,如Authority等
3,實例化一個RestRequest對象
4,添加RestRequest的請求參數
5,使用RestClient實例的BeginRequest方法進行異步請求
6,處理回調函數
參考文章:Facebook Integration via Hammock