本文整理汇总了C#中Api.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Api.Get方法的具体用法?C# Api.Get怎么用?C# Api.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrivateAppSample
/// <summary>
/// 私有应用API使用方法。
/// </summary>
private static void PrivateAppSample()
{
var auth = new PrivateAppAuth(appKey, appSecret);
var token = auth.GetToken();
var api = new Api(token);
var response = api.Get("customers");
Console.WriteLine(response.Content);
}
示例2: PublicAppSample
/// <summary>
/// 公有应用API使用方法。
/// </summary>
private static void PublicAppSample()
{
var auth = new PublicAppAuth(appKey, appSecret, appRedirectUrl, "read_basic");
var token = auth.GetToken(code);
Console.WriteLine(token);
var api = new Api(token);
var response = api.Get("customers");
Console.WriteLine(response.Content);
}
示例3: CanUseHalClient
public async Task CanUseHalClient()
{
using (var hal = GetHalClient())
{
// Get the api
// Note : This is done by setting up api object and refreshing it with a GET call
var api = new Api { Self = new HalLink(@"http://api.example.com") };
api = await api.Get(hal);
// Create a new session
var session =
await
api.Sessions.Post(
new Session { User = new User { Email = @"[email protected]", Password = "admin" } }, hal);
Assert.IsNotNull(session);
// Create a new user
var newuser = await api.Users.Post(new User { Email = @"[email protected]", Password = "password" }, hal);
Assert.IsNotNull(newuser);
// Get sessions
var sessions = await api.Sessions.Get(hal);
Assert.IsNotNull(sessions);
// Get users
var users = await api.Users.Get(hal);
Assert.IsNotNull(users);
// Update user
newuser.Password = "newpassword";
var updatedUser = await newuser.Put(hal);
Assert.IsNotNull(updatedUser);
// Delete user
await updatedUser.Delete(hal);
// Logout
await session.Delete(hal);
}
}