예제 #1
0
        public object GetWordpressInfo()
        {
            var token = WordpressToken.GetToken();

            if (token != null)
            {
                var meInfo            = WordpressHelper.GetWordpressMeInfo(token.AccessToken);
                var blogId            = JObject.Parse(meInfo).Value <string>("token_site_id");
                var wordpressUserName = JObject.Parse(meInfo).Value <string>("username");

                var blogInfo     = RequestHelper.PerformRequest(WordpressLoginProvider.WordpressSites + blogId, "", "GET", "");
                var jsonBlogInfo = JObject.Parse(blogInfo);
                jsonBlogInfo.Add("username", wordpressUserName);

                blogInfo = jsonBlogInfo.ToString();
                return(new
                {
                    success = true,
                    data = blogInfo
                });
            }
            return(new
            {
                success = false
            });
        }
예제 #2
0
        public bool CreateWordpressPost(string code, string title, string content, int status)
        {
            try
            {
                var token  = WordpressToken.GetToken();
                var meInfo = WordpressHelper.GetWordpressMeInfo(token.AccessToken);
                var parser = JObject.Parse(meInfo);
                if (parser == null)
                {
                    return(false);
                }
                var blogId = parser.Value <string>("token_site_id");

                if (blogId != null)
                {
                    var createPost = WordpressHelper.CreateWordpressPost(title, content, status, blogId, token);
                    return(createPost);
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #3
0
        public object DeleteWordpressInfo()
        {
            var token = WordpressToken.GetToken();

            if (token != null)
            {
                WordpressToken.DeleteToken(token);
                return(new
                {
                    success = true
                });
            }
            return(new
            {
                success = false
            });
        }