Created
March 28, 2011 17:26
-
-
Save prabirshrestha/890884 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void Get() | |
| { | |
| var ms = new MemoryStream(); | |
| var request = new FluentHttpRequest() | |
| .BaseUrl("https://graph.facebook.com") | |
| .ResourcePath("/prabirshrestha") | |
| .Method("GET") | |
| .QueryStrings(qs => | |
| qs | |
| .Add("fields", "id,name") | |
| .Add("format", "json")) | |
| .Headers(h => h.Add("User-Agent", "Fluent Http")) | |
| .OnResponseHeadersReceived((o, e) => { e.ResponseSaveStream = ms; }); | |
| var ar = request.BeginExecute(null, null); | |
| var response = request.EndExecute(ar); | |
| ms.Seek(0, SeekOrigin.Begin); | |
| Console.WriteLine(new StreamReader(ms).ReadToEnd()); | |
| } | |
| private static void Post() | |
| { | |
| var ms = new MemoryStream(); | |
| var request = new FluentHttpRequest() | |
| .BaseUrl("https://graph.facebook.com") | |
| .ResourcePath("/me/feed") | |
| .Method("POST") | |
| .QueryStrings(qs => | |
| qs | |
| .Add("format", "json")) | |
| .Headers(h => h | |
| .Add("User-Agent", "Fluent Http") | |
| .Add("Content-Type", "application/x-www-form-urlencoded")) | |
| .Body(body => | |
| body | |
| .Append("message=hello")) | |
| .AuthenticateUsing(new OAuth2AuthorizationRequestHeaderAuthenticator(AccessToken)) | |
| .OnResponseHeadersReceived((o, e) => e.ResponseSaveStream = ms); | |
| var ar = request.BeginExecute(null, null); | |
| var response = request.EndExecute(ar); | |
| ms.Seek(0, SeekOrigin.Begin); | |
| Console.WriteLine(new StreamReader(ms).ReadToEnd()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment