2016-12-10 17 views
-2

C#でSNSで使用可能なトピックをリストする方法はありますか?C# - AWS SNSリストのトピック

Webアプリケーションのドロップダウンにリストを表示したいとします。

ご協力いただければ幸いです。

おかげで、

アナンド

+0

私にdownvoteの良い理由を教えてください。そのような質問をするのは罪でしょうか? –

答えて

0

公式ドキュメントではそのための良い例があります。

// using Amazon.SimpleNotificationService; 
// using Amazon.SimpleNotificationService.Model; 

var client = new AmazonSimpleNotificationServiceClient(); 
var request = new ListTopicsRequest(); 
var response = new ListTopicsResponse(); 

do 
{ 
    response = client.ListTopics(request); 

    foreach (var topic in response.Topics) 
    { 
    Console.WriteLine("Topic: {0}", topic.TopicArn); 

    var subs = client.ListSubscriptionsByTopic(
     new ListSubscriptionsByTopicRequest 
     { 
     TopicArn = topic.TopicArn 
     }); 

    var ss = subs.Subscriptions; 

    if (ss.Any()) 
    { 
     Console.WriteLine(" Subscriptions:"); 

     foreach (var sub in ss) 
     { 
     Console.WriteLine(" {0}", sub.SubscriptionArn); 
     } 
    } 

    var attrs = client.GetTopicAttributes(
     new GetTopicAttributesRequest 
     { 
     TopicArn = topic.TopicArn 
     }).Attributes; 

    if (attrs.Any()) 
    { 
     Console.WriteLine(" Attributes:"); 

     foreach (var attr in attrs) 
     { 
     Console.WriteLine(" {0} = {1}", attr.Key, attr.Value); 
     } 
    }  

    Console.WriteLine(); 
    } 

    request.NextToken = response.NextToken; 

} while (!string.IsNullOrEmpty(response.NextToken)); 
関連する問題