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 }); }
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); } }
public object DeleteWordpressInfo() { var token = WordpressToken.GetToken(); if (token != null) { WordpressToken.DeleteToken(token); return(new { success = true }); } return(new { success = false }); }