Ejemplo n.º 1
0
        public void SetShareWeiBo(string AccessToken)
        {
            Sina = new Client(new OAuth(ConfigurationManager.AppSettings["AppKey"]
                                        , ConfigurationManager.AppSettings["AppSecret"]
                                        , AccessToken
                                        , null));
            string url1 = "http://ww2.sinaimg.cn/thumbnail/3dc6b9d8jw1ea5iae1vkej203i00o743.jpg";

            //string url = "E:\\CloudPos\\svnNew\\CPOS_New\\Code\\CPOS.Web\\Weibo\\images\\240.png";
            string wbContent = "上海市静安区延平路121号三和大厦 15层D座";

            JIT.CPOS.BS.BLL.WX.CommonBLL server = new BS.BLL.WX.CommonBLL();
            string urlx = server.DownloadFile(url1);

            //dynamic result = Sina.API.Dynamic.Statuses.Update(wbContent); //分享微博文本
            try
            {
                dynamic r = Sina.API.Dynamic.Statuses.Upload(wbContent, byteImage(urlx));    //分享微博内容
            }
            catch (Exception ex) {
                Response.Write(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public string setSinaWbShare()
        {
            string content  = string.Empty;
            var    respData = new setSinaWbShareRespData();

            try
            {
                string reqContent = Request["ReqContent"];

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("setSinaWbShare: {0}", reqContent)
                });

                //解析请求字符串
                var reqObj = reqContent.DeserializeJSONTo <setSinaWbShareReqData>();
                reqObj = reqObj == null ? new setSinaWbShareReqData() : reqObj;
                if (reqObj.special == null)
                {
                    reqObj.special = new setSinaWbShareReqSpecialData();
                }
                if (reqObj.special == null)
                {
                    respData.code        = "2201";
                    respData.description = "特殊参数不能为空";
                    return(respData.ToJSON().ToString());
                }

                if (reqObj.special.resultUrl == null || reqObj.special.resultUrl.Equals(""))
                {
                    respData.code        = "2201";
                    respData.description = "返回地址不能为空";
                    return(respData.ToJSON().ToString());
                }

                //判断客户ID是否传递
                if (!string.IsNullOrEmpty(reqObj.common.customerId))
                {
                    customerId = reqObj.common.customerId;
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                #region
                VipExpandSinaWbBLL    server = new VipExpandSinaWbBLL(loggingSessionInfo);
                VipExpandSinaWbEntity info   = server.GetByID(reqObj.common.userId);
                if (info == null || info.AccessToken == null)
                {
                    respData.code        = "103";
                    respData.description = "不存在对应的token";
                    return(respData.ToJSON().ToString());
                }

                Sina = new Client(new OAuth(ConfigurationManager.AppSettings["AppKey"]
                                            , ConfigurationManager.AppSettings["AppSecret"]
                                            , info.AccessToken
                                            , null));
                string imageUrl = reqObj.special.imageUrl;
                string Text     = reqObj.special.text;
                if ((imageUrl == null || imageUrl.Equals("")) && (Text == null || Text.Equals("")))
                {
                    respData.code        = "103";
                    respData.description = "分享信息为空";
                    return(respData.ToJSON().ToString());
                }
                VipWeiboShareLogBLL    logServer = new VipWeiboShareLogBLL(loggingSessionInfo);
                VipWeiboShareLogEntity logInfo   = new VipWeiboShareLogEntity();
                logInfo.LogId       = BaseService.NewGuidPub();
                logInfo.AccessToken = info.AccessToken;
                logInfo.VipId       = info.VipId;
                logInfo.ImageUrl    = imageUrl;
                logInfo.Text        = Text;
                logInfo.ShareType   = "Sina";
                if (imageUrl == null || imageUrl.Equals(""))
                {
                    try
                    {
                        dynamic result = Sina.API.Dynamic.Statuses.Update(Text); //分享微博文本
                        logInfo.IsSuccess = 1;
                    }
                    catch (Exception ex1) {
                        logInfo.IsSuccess = 0;
                        if (ex1.ToString().Length > 200)
                        {
                            logInfo.FailureResason = ex1.ToString().Substring(0, 199);
                        }
                        else
                        {
                            logInfo.FailureResason = ex1.ToString();
                        }
                        respData.code        = "103";
                        respData.description = ex1.ToString();
                    }
                }
                else
                {
                    JIT.CPOS.BS.BLL.WX.CommonBLL serverBLL = new BS.BLL.WX.CommonBLL();
                    string urlx = serverBLL.DownloadFile(imageUrl);
                    try
                    {
                        dynamic r = Sina.API.Dynamic.Statuses.Upload(Text, byteImage(urlx));    //分享微博内容
                        logInfo.IsSuccess = 1;
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.ToString());
                        logInfo.IsSuccess = 0;
                        if (ex.ToString().Length > 200)
                        {
                            logInfo.FailureResason = ex.ToString().Substring(0, 199);
                        }
                        else
                        {
                            logInfo.FailureResason = ex.ToString();
                        }
                        respData.code        = "103";
                        respData.description = ex.ToString();
                    }
                }
                logServer.Create(logInfo);
                #endregion
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                respData.exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }