示例#1
0
        /// <summary>
        /// 获得板块信息
        /// </summary>
        /// <returns></returns>
        public string Get()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return("");
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return("");
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return("");
            }

            if (!CheckRequiredParams("fid"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            int fid = Utils.StrToInt(GetParam("fid"), 0);

            if (fid < 1)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(fid);

            if (forumInfo == null)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }
            //string forumurl = "http://" + DNTRequest.GetCurrentFullHost() + BaseConfigs.GetForumPath.ToLower();

            ForumGetResponse fgr = new ForumGetResponse();

            fgr.Fid           = fid;
            fgr.Url           = ForumUrl + Urls.ShowForumAspxRewrite(fid, 1, forumInfo.Rewritename);
            fgr.CurTopics     = forumInfo.CurrentTopics;
            fgr.Description   = forumInfo.Description;
            fgr.Icon          = forumInfo.Icon;
            fgr.LastPost      = forumInfo.Lastpost;
            fgr.LastPoster    = forumInfo.Lastposter.Trim();
            fgr.LastPosterId  = forumInfo.Lastposterid;
            fgr.LastTid       = forumInfo.Lasttid;
            fgr.LastTitle     = forumInfo.Lasttitle.Trim();
            fgr.Moderators    = forumInfo.Moderators;
            fgr.Name          = forumInfo.Name;
            fgr.ParentId      = forumInfo.Parentid;
            fgr.ParentIdList  = forumInfo.Parentidlist.Trim();
            fgr.PathList      = forumInfo.Pathlist.Trim();
            fgr.Posts         = forumInfo.Posts;
            fgr.Rules         = forumInfo.Rules;
            fgr.Status        = forumInfo.Status;
            fgr.SubForumCount = forumInfo.Subforumcount;
            fgr.TodayPosts    = forumInfo.Todayposts;
            fgr.Topics        = forumInfo.Topics;


            if (Format == FormatType.JSON)
            {
                return(JsonConvert.SerializeObject(fgr));
            }
            return(SerializationHelper.Serialize(fgr));
        }
示例#2
0
        /// <summary>
        /// 获得板块信息
        /// </summary>
        /// <returns></returns>
        public string Get()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return "";
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return "";
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return "";
            }

            if (!CheckRequiredParams("fid"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return "";
            }

            int fid = Utils.StrToInt(GetParam("fid"), 0);
            if (fid < 1)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return "";
            }

            ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(fid);
            if (forumInfo == null)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return "";
            }
            //string forumurl = "http://" + DNTRequest.GetCurrentFullHost() + BaseConfigs.GetForumPath.ToLower();

            ForumGetResponse fgr = new ForumGetResponse();
            fgr.Fid = fid;
            fgr.Url = ForumUrl + Urls.ShowForumAspxRewrite(fid, 1, forumInfo.Rewritename);
            fgr.CurTopics = forumInfo.CurrentTopics;
            fgr.Description = forumInfo.Description;
            fgr.Icon = forumInfo.Icon;
            fgr.LastPost = forumInfo.Lastpost;
            fgr.LastPoster = forumInfo.Lastposter.Trim();
            fgr.LastPosterId = forumInfo.Lastposterid;
            fgr.LastTid = forumInfo.Lasttid;
            fgr.LastTitle = forumInfo.Lasttitle.Trim();
            fgr.Moderators = forumInfo.Moderators;
            fgr.Name = forumInfo.Name;
            fgr.ParentId = forumInfo.Parentid;
            fgr.ParentIdList = forumInfo.Parentidlist.Trim();
            fgr.PathList = forumInfo.Pathlist.Trim();
            fgr.Posts = forumInfo.Posts;
            fgr.Rules = forumInfo.Rules;
            fgr.Status = forumInfo.Status;
            fgr.SubForumCount = forumInfo.Subforumcount;
            fgr.TodayPosts = forumInfo.Todayposts;
            fgr.Topics = forumInfo.Topics;


            if (Format == FormatType.JSON)
            {
                return JavaScriptConvert.SerializeObject(fgr);
            }
            return SerializationHelper.Serialize(fgr);
        }
示例#3
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            //如果是桌面程序则需要验证用户身份
            //if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP)
            //{
            //    if (commandParam.LocalUid < 1)
            //    {
            //        result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList);
            //        return false;
            //    }
            //}

            if (!commandParam.CheckRequiredParams("fid"))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return false;
            }

            int fid = Utils.StrToInt(commandParam.GetDNTParam("fid"), 0);
            if (fid < 1)
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return false;
            }

            ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(fid);
            if (forumInfo == null)
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_FORUM_NOT_EXIST, commandParam.ParamList);
                return false;
            }

            ForumGetResponse fgr = new ForumGetResponse();
            fgr.Fid = fid;
            fgr.Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Urls.ShowForumAspxRewrite(fid, 1, forumInfo.Rewritename);
            fgr.CurTopics = forumInfo.CurrentTopics;
            fgr.Description = forumInfo.Description;
            fgr.Icon = forumInfo.Icon;
            fgr.LastPost = forumInfo.Lastpost;
            fgr.LastPoster = forumInfo.Lastposter.Trim();
            fgr.LastPosterId = forumInfo.Lastposterid;
            fgr.LastTid = forumInfo.Lasttid;
            fgr.LastTitle = forumInfo.Lasttitle.Trim();
            fgr.Moderators = forumInfo.Moderators;
            fgr.Name = forumInfo.Name;
            fgr.ParentId = forumInfo.Parentid;
            fgr.ParentIdList = forumInfo.Parentidlist.Trim();
            fgr.PathList = forumInfo.Pathlist.Trim();
            fgr.Posts = forumInfo.Posts;
            fgr.Rules = forumInfo.Rules;
            fgr.Status = forumInfo.Status;
            fgr.SubForumCount = forumInfo.Subforumcount;
            fgr.TodayPosts = forumInfo.Todayposts;
            fgr.Topics = forumInfo.Topics;

            result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(fgr) : SerializationHelper.Serialize(fgr);
            return true;
        }
示例#4
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            //如果是桌面程序则需要验证用户身份
            //if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP)
            //{
            //    if (commandParam.LocalUid < 1)
            //    {
            //        result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList);
            //        return false;
            //    }
            //}

            if (!commandParam.CheckRequiredParams("fid"))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return(false);
            }

            int fid = Utils.StrToInt(commandParam.GetDNTParam("fid"), 0);

            if (fid < 1)
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return(false);
            }

            ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(fid);

            if (forumInfo == null)
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_FORUM_NOT_EXIST, commandParam.ParamList);
                return(false);
            }

            ForumGetResponse fgr = new ForumGetResponse();

            fgr.Fid           = fid;
            fgr.Url           = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Urls.ShowForumAspxRewrite(fid, 1, forumInfo.Rewritename);
            fgr.CurTopics     = forumInfo.CurrentTopics;
            fgr.Description   = forumInfo.Description;
            fgr.Icon          = forumInfo.Icon;
            fgr.LastPost      = forumInfo.Lastpost;
            fgr.LastPoster    = forumInfo.Lastposter.Trim();
            fgr.LastPosterId  = forumInfo.Lastposterid;
            fgr.LastTid       = forumInfo.Lasttid;
            fgr.LastTitle     = forumInfo.Lasttitle.Trim();
            fgr.Moderators    = forumInfo.Moderators;
            fgr.Name          = forumInfo.Name;
            fgr.ParentId      = forumInfo.Parentid;
            fgr.ParentIdList  = forumInfo.Parentidlist.Trim();
            fgr.PathList      = forumInfo.Pathlist.Trim();
            fgr.Posts         = forumInfo.Posts;
            fgr.Rules         = forumInfo.Rules;
            fgr.Status        = forumInfo.Status;
            fgr.SubForumCount = forumInfo.Subforumcount;
            fgr.TodayPosts    = forumInfo.Todayposts;
            fgr.Topics        = forumInfo.Topics;

            result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(fgr) : SerializationHelper.Serialize(fgr);
            return(true);
        }