示例#1
0
 public static async Task<HttpResponseMessage> FollowUser(Uri userUrl)
 {
     il.AddCurrentLoginStatus("Attempting to GET User resource...");
     try
     {
         if (0 != Settings.Default.OAuthToken.Trim().Length)
         {
             il.AddCurrentLoginStatus("OAuth token is available; attempting request with Authorization HTTP header attached...");
             Settings.Default.DomainAddress = userUrl.AbsoluteUri.Replace(userUrl.PathAndQuery, String.Empty);
             LyncHttpClient = new LyncHttpClient();
             return await LyncHttpClient.GetAsync(userUrl);
         }
         else
         {
             il.AddCurrentLoginStatus("OAuth token was not found; attempting request without Authorization header...");
             return await httpClient.GetAsync(userUrl);
         }
     }
     catch (Exception ex)
     {
         il.AddCurrentLoginStatus(String.Format("Failed this time. Status Code: {0}\nMessage: {1}\n", response.StatusCode.ToString(), ex.Message.ToString()));
     }
     return new HttpResponseMessage(HttpStatusCode.BadRequest);
 }