Ejemplo n.º 1
0
        public async void SendAuth()
        {
            try
            {
                SendAuth.Req req = new SendAuth.Req(AppSettings.Scope, "test");

                IWXAPI api = WXAPIFactory.CreateWXAPI(AppSettings.AppId);
                var isValid = await api.SendReq(req);
            }
            catch (WXException ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                try
                {
                    SendAuth.Req req = new SendAuth.Req("[YOUR SCOPE]", "test");

                    IWXAPI api = WXAPIFactory.CreateWXAPI("[YOUR APP ID]");
                    var isok = await api.SendReqAsync(req);
                }
                catch (WXException)
                {
                }

                //int scene = SendMessageToWX.Req.WXSceneTimeline; //发给微信朋友

                //var file = await Package.Current.InstalledLocation.GetFileAsync("1.png");
                //using (var stream = await file.OpenReadAsync())
                //{
                //    var pic = new byte[stream.Size];
                //    await stream.AsStream().ReadAsync(pic, 0, pic.Length);

                //    var message = new WXWebpageMessage
                //    {
                //        WebpageUrl = "http://www.baidu.com",
                //        Title = "title",
                //        Description = "desc",
                //        ThumbData = pic
                //    };

                //    try
                //    {
                //        SendMessageToWX.Req req = new SendMessageToWX.Req(message, scene);
                //        IWXAPI api = WXAPIFactory.CreateWXAPI("[YOUR APP ID]");
                //        var isok = await api.SendReq(req);
                //    }
                //    catch (WXException)
                //    {
                //    }
                //}

                //var message = new WXTextMessage();
                //message.Title = "flora";
                //message.Text = "这是一段文本内容";
                //message.ThumbData = null;
                //SendMessageToWX.Req req = new SendMessageToWX.Req(message, scene);
                //IWXAPI api = WXAPIFactory.CreateWXAPI("[YOUR APP ID]");
                //var isok = await api.SendReq(req);

                //WXImageMessage message = new WXImageMessage();
                //var file = await Package.Current.InstalledLocation.GetFileAsync("1.png");
                //using (var stream = await file.OpenReadAsync())
                //{
                //    var pic = new byte[stream.Size];
                //    await stream.AsStream().ReadAsync(pic, 0, pic.Length);
                //    message.Title = "tupian";
                //    message.Description = "desc";
                //    message.ThumbData = pic;
                //    message.ImageUrl = "http://tp3.sinaimg.cn/1882347990/180/5725518284/1";

                //    try
                //    {
                //        SendMessageToWX.Req req = new SendMessageToWX.Req(message, scene);
                //        IWXAPI api = WXAPIFactory.CreateWXAPI("[YOUR APP ID]");
                //        var isok = await api.SendReq(req);
                //    }
                //    catch (WXException)
                //    {
                //    }
                //}
            }
            catch (Exception ex)
            {
                //new MessageDialog(ex.Message).ShowAsync();
            }
        }
Ejemplo n.º 3
0
        internal void FromProto(object protoObj)
        {
            TransactDataP ap = protoObj as TransactDataP;

            if (ap != null)
            {
                ConmandId    = (int)ap.ConmandID;
                AppId        = ap.AppID;
                SdkVersion   = ap.SdkVersion;
                CheckContent = ap.CheckContent;
                CheckSummary = ap.CheckSummary;
                if (!string.IsNullOrEmpty(ap.GetReq.Base.Transaction))
                {
                    Req = new GetMessageFromWX.Req();
                    Req.FromProto(ap.GetReq);
                }
                if (!string.IsNullOrEmpty(ap.AuthReq.Base.Transaction))
                {
                    Req = new SendAuth.Req();
                    Req.FromProto(ap.AuthReq);
                }
                if (!string.IsNullOrEmpty(ap.SendReq.Base.Transaction))
                {
                    Req = new SendMessageToWX.Req();
                    Req.FromProto(ap.SendReq);
                }
                if (!string.IsNullOrEmpty(ap.ShowReq.Base.Transaction))
                {
                    Req = new ShowMessageFromWX.Req();
                    Req.FromProto(ap.ShowReq);
                }
                if (!string.IsNullOrEmpty(ap.GetResp.Base.Transaction))
                {
                    Resp = new GetMessageFromWX.Resp();
                    Resp.FromProto(ap.GetResp);
                }
                if (!string.IsNullOrEmpty(ap.AuthResp.Base.Transaction))
                {
                    Resp = new SendAuth.Resp();
                    Resp.FromProto(ap.AuthResp);
                }
                if (!string.IsNullOrEmpty(ap.SendResp.Base.Transaction))
                {
                    Resp = new SendMessageToWX.Resp();
                    Resp.FromProto(ap.SendResp);
                }
                if (!string.IsNullOrEmpty(ap.ShowResp.Base.Transaction))
                {
                    Resp = new ShowMessageFromWX.Resp();
                    Resp.FromProto(ap.ShowResp);
                }
                if (!string.IsNullOrEmpty(ap.PayReq.Base.Transaction))
                {
                    Req = new SendPay.Req();
                    Req.FromProto(ap.PayReq);
                }
                if (!string.IsNullOrEmpty(ap.PayResp.Base.Transaction))
                {
                    Resp = new SendPay.Resp();
                    Resp.FromProto(ap.PayResp);
                }
            }
        }
Ejemplo n.º 4
0
 internal void FromProto(object protoObj)
 {
     TransactDataP ap = protoObj as TransactDataP;
     if (ap != null)
     {
         ConmandId = (int)ap.ConmandID;
         AppId = ap.AppID;
         SdkVersion = ap.SdkVersion;
         CheckContent = ap.CheckContent;
         CheckSummary = ap.CheckSummary;
         if (!string.IsNullOrEmpty(ap.GetReq.Base.Transaction))
         {
             Req = new GetMessageFromWX.Req();
             Req.FromProto(ap.GetReq);
         }
         if (!string.IsNullOrEmpty(ap.AuthReq.Base.Transaction))
         {
             Req = new SendAuth.Req();
             Req.FromProto(ap.AuthReq);
         }
         if (!string.IsNullOrEmpty(ap.SendReq.Base.Transaction))
         {
             Req = new SendMessageToWX.Req();
             Req.FromProto(ap.SendReq);
         }
         if (!string.IsNullOrEmpty(ap.ShowReq.Base.Transaction))
         {
             Req = new ShowMessageFromWX.Req();
             Req.FromProto(ap.ShowReq);
         }
         if (!string.IsNullOrEmpty(ap.GetResp.Base.Transaction))
         {
             Resp = new GetMessageFromWX.Resp();
             Resp.FromProto(ap.GetResp);
         }
         if (!string.IsNullOrEmpty(ap.AuthResp.Base.Transaction))
         {
             Resp = new SendAuth.Resp();
             Resp.FromProto(ap.AuthResp);
         }
         if (!string.IsNullOrEmpty(ap.SendResp.Base.Transaction))
         {
             Resp = new SendMessageToWX.Resp();
             Resp.FromProto(ap.SendResp);
         }
         if (!string.IsNullOrEmpty(ap.ShowResp.Base.Transaction))
         {
             Resp = new ShowMessageFromWX.Resp();
             Resp.FromProto(ap.ShowResp);
         }
         if (!string.IsNullOrEmpty(ap.PayReq.Base.Transaction))
         {
             Req = new SendPay.Req();
             Req.FromProto(ap.PayReq);
         }
         if (!string.IsNullOrEmpty(ap.PayResp.Base.Transaction))
         {
             Resp = new SendPay.Resp();
             Resp.FromProto(ap.PayResp);
         }
     }
 }