public static Task <Status> ShareAsync(this IWeiboClient client, string status, byte[] image, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (status == null)
            {
                throw new ArgumentNullException(nameof(status));
            }
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            var postContent = new MultipartFormDataContent
            {
                {
                    new StringContent(status), "status"
                },
                {
                    new ByteArrayContent(image), "pic"
                }
            };

            return(client.PostAsync <Status>("/statuses/share.json", postContent, cancellationToken));
        }
        public static Task <User> GetCurrentUserAsync(this IWeiboClient client, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            return(client.GetUserAsync(client.UserId, cancellationToken));
        }
        public static Task GetUserTimelineAsync(this IWeiboClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            throw new NotImplementedException();
        }
        public static Task <User> GetUserAsync(this IWeiboClient client, long userId, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            return(client.GetAsync <User>($"/users/show.json?uid={userId}", cancellationToken));
        }
        public MainWindow()
        {
            _client = new WeiboClientBuilder()
                      .WithConfig(appKey: "393209958", appSecret: "3c2387aa56497a4ed187f146afc8cb34", redirectUri: "http://bing.coding.io/")
                      .UseDefaultAuthorizationProvider()
                      .UseDefaultAccessTokenStorage()
                      .Build();

            InitializeComponent();
        }
Beispiel #6
0
        public SinaWeiboService(string accessToken, string accessTokenSecret)
        {
            if (accessToken.IsNullOrEmpty())
                throw new ArgumentException("accessToken不能为空", "accessToken");

            if (accessTokenSecret.IsNullOrEmpty())
                throw new ArgumentException("accessTokenSecret不能为空", "accessTokenSecret");

            var token = new AccessToken(ConsumerFactory.SinaConsumer, accessToken, accessTokenSecret);
            _weiboClient = new WeiboClient(token, ResultFormat.json);
        }
        public static async Task <Status> ShareAsync(this IWeiboClient client, string status, StorageFile imageFile, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (status == null)
            {
                throw new ArgumentNullException(nameof(status));
            }
            if (imageFile == null)
            {
                throw new ArgumentNullException(nameof(imageFile));
            }

            var image = (await FileIO.ReadBufferAsync(imageFile)).ToArray();

            return(await client.ShareAsync(status, image, cancellationToken));
        }
        public static Task <Status> ShareAsync(this IWeiboClient client, string status, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (status == null)
            {
                throw new ArgumentNullException(nameof(status));
            }

            var postData = new Dictionary <string, string>
            {
                ["status"] = status
            };
            var postContent = new FormUrlEncodedContent(postData);

            return(client.PostAsync <Status>("/statuses/share.json", postContent, cancellationToken));
        }
        /// <summary>
        /// 回复一条评论 https://open.weibo.com/wiki/2/comments/reply
        /// </summary>
        /// <param name="client"></param>
        /// <param name="commentId">需要回复的评论 Id。</param>
        /// <param name="statusId">需要评论的微博 Id。</param>
        /// <param name="comment">回复评论内容,内容不超过 140 个汉字。</param>
        /// <param name="withoutMention">回复中是否自动加入“回复@用户名”。</param>
        /// <param name="commentOriginalStatus">当评论转发微博时,是否评论给原微博。</param>
        /// <returns></returns>
        public static Task <Comment> ReplyAsync(this IWeiboClient client, int commentId, int statusId, string comment, bool withoutMention = true, bool commentOriginalStatus = false, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (comment == null)
            {
                throw new ArgumentNullException(nameof(comment));
            }

            var postData = new Dictionary <string, string>
            {
                ["cid"]             = commentId.ToString(),
                ["id"]              = statusId.ToString(),
                ["comment"]         = comment,
                ["without_mention"] = withoutMention ? "0" : "1",
                ["comment_ori"]     = commentOriginalStatus ? "1" : "0"
            };
            var postContent = new FormUrlEncodedContent(postData);

            return(client.PostAsync <Comment>("/comments/reply.json", postContent, cancellationToken));
        }
Beispiel #10
0
 public SinaWeiboService(IWeiboClient weiboClient)
 {
     _weiboClient = weiboClient;
 }
Beispiel #11
0
 public QQTestBase()
 {
     var accessToken = new AccessToken(ConsumerFactory.QQConsumer, ConfigurationManager.AppSettings["QQAccessToken"], ConfigurationManager.AppSettings["QQAccessTokenSecret"]);
     WeiboClient = new WeiboClient(accessToken, ResultFormat.json);
 }
Beispiel #12
0
        protected SinaTestBase()
        {
            var accessToken = new AccessToken(ConsumerFactory.SinaConsumer, ConfigurationManager.AppSettings["SinaAccessToken"], ConfigurationManager.AppSettings["SinaAccessTokenSecret"]);

            WeiboClient = new WeiboClient(accessToken, ResultFormat.json);
        }
Beispiel #13
0
 protected SinaTestBase()
 {
     var accessToken = new AccessToken(ConsumerFactory.SinaConsumer, ConfigurationManager.AppSettings["SinaAccessToken"], ConfigurationManager.AppSettings["SinaAccessTokenSecret"]);
     WeiboClient = new WeiboClient(accessToken, ResultFormat.json);
 }
Beispiel #14
0
        public QQTestBase()
        {
            var accessToken = new AccessToken(ConsumerFactory.QQConsumer, ConfigurationManager.AppSettings["QQAccessToken"], ConfigurationManager.AppSettings["QQAccessTokenSecret"]);

            WeiboClient = new WeiboClient(accessToken, ResultFormat.json);
        }