Exemple #1
0
        private async Task <FeedItem> postFeedItem(IChatterClient chatter)
        {
            var me = await chatter.MeAsync <UserDetail>();

            var id = me.id;

            var messageSegment = new MessageSegmentInput
            {
                Text = "Testing 1, 2, 3",
                Type = "Text"
            };

            var body = new MessageBodyInput {
                MessageSegments = new List <MessageSegmentInput> {
                    messageSegment
                }
            };
            var feedItemInput = new FeedItemInput()
            {
                Attachment      = null,
                Body            = body,
                SubjectId       = id,
                FeedElementType = "FeedItem"
            };

            var feedItem = await chatter.PostFeedItemAsync <FeedItem>(feedItemInput, id);

            return(feedItem);
        }
Exemple #2
0
        public void Init()
        {
            if (string.IsNullOrEmpty(_consumerKey) && string.IsNullOrEmpty(_consumerSecret) && string.IsNullOrEmpty(_username) && string.IsNullOrEmpty(_password))
            {
                _consumerKey    = Environment.GetEnvironmentVariable("ConsumerKey");
                _consumerSecret = Environment.GetEnvironmentVariable("ConsumerSecret");
                _username       = Environment.GetEnvironmentVariable("Username");
                _password       = Environment.GetEnvironmentVariable("Password");
            }

            // Use TLS 1.2 (instead of defaulting to 1.0)
            const int SecurityProtocolTypeTls11 = 768;
            const int SecurityProtocolTypeTls12 = 3072;

            ServicePointManager.SecurityProtocol |= (SecurityProtocolType)(SecurityProtocolTypeTls12 | SecurityProtocolTypeTls11);

            _auth = new AuthenticationClient();
            _auth.UsernamePasswordAsync(_consumerKey, _consumerSecret, _username, _password, TokenRequestEndpointUrl, CancellationToken.None).Wait();

            _chatterClient = new ChatterClient(_auth.InstanceUrl, _auth.AccessToken, _auth.ApiVersion);
        }