我在 API 文档中引用了这一部分,但我不确定我通过 API 发出的请求是否正确。这就是我的代码的样子:
public class CfListInvalidation
{
string accessKeyID = ConfigurationManager.AppSettings["awsAccessID"];
string secretAccessKeyID = ConfigurationManager.AppSettings["awsSecretAnswer"];
string distributionId = ConfigurationManager.AppSettings["distributionId"];
AmazonCloudFront client;
public void SendCommand()
{
Console.WriteLine("Connecting to Amazon Cloud Front...");
using (client = AWSClientFactory.CreateAmazonCloudFrontClient(accessKeyID, secretAccessKeyID))
{
ListInvalidationsResult result = new ListInvalidationsResult();
IAsyncResult r = client.BeginListInvalidations(new ListInvalidationsRequest
{
DistributionId = distributionId,
}, new AsyncCallback(CfListInvalidation.CompleteRead), result );
}
}
static void CompleteRead(IAsyncResult result)
{
ListInvalidationsResult r = result.AsyncState as ListInvalidationsResult;
if (r != null && r.InvalidationList != null)
{
Console.WriteLine("listing items..");
foreach (InvalidationSummary s in r.InvalidationList.Items)
{
Console.WriteLine(string.Format("ID: {0} - Status: {1}", s.Id, s.Status));
}
}
else {
Console.WriteLine("No Items Found");
}
}
}
难道我做错了什么?