private void button1_Click(object sender, EventArgs e) { string test = MessageAPI.GetToken(); txt_token.Text = test; token = test; }
protected void Button2_Click(object sender, EventArgs e) { //create client with the help of access token as parameter which is stored in session. LoginRadiusClient client = new LoginRadiusClient((LoginRadiusAccessToken)Session["token"]); //create object to execute message api to send message on twitter and linkedin MessageAPI sendMessage = new MessageAPI(); //fill fields to send message sendMessage.To = to.Text; sendMessage.Subject = subject.Text; sendMessage.Message = message.Text; // send message on twitter and linkedin with the help of MessageAPI object as parameter //pass LoginRadiusPostResponse model as interface to map loginradius post response. var response = client.GetResponse <LoginRadiusPostResponse>(sendMessage); if (response.isPosted == true) { issend.InnerText = "Successfully sent!!"; } else { issend.InnerText = "Not sent!!"; } }
private void button5_Click(object sender, EventArgs e) { //url = "http://api.ema666.com/Api/userExit?token=" + token; //string res = GetHtml(url); string res = MessageAPI.Exit(token); txt_exit.Text = res; }
/// <summary> /// 回复图文消息 /// </summary> /// <param name="re"></param> /// <param name="title"></param> /// <param name="description"></param> /// <param name="picUrl"></param> /// <param name="redrectUrl"></param> /// <returns></returns> public ContentResult ReplyImage(string title, string description, string picUrl, string redrectUrl) { ContentResult result = new ContentResult(); var sendXml = MessageAPI.GetSendContext(_messageAPI.Message); var xe = MessageAPI.GetSendImageContext(sendXml, title, description, picUrl, redrectUrl); result.Content = MessageAPI.SendEncryptMsg(_messageAPI, xe); return(result); }
private void button7_Click(object sender, EventArgs e) { string p = txt_phone2.Text.Trim(); string res = MessageAPI.GetPhone(token, p); phone = p; txt_phone.Text = p; txt_phone2.Text = res; }
private void button6_Click(object sender, EventArgs e) { //url = "http://api.ema666.com/Api/userAddBlack?token=" + token + "&phoneList=" + phone + ";"; //string res = GetHtml(url); string res = MessageAPI.AddBlack(token, phone); txt_heimingdan.Text = res; }
private void button4_Click(object sender, EventArgs e) { //释放全部手机号码 http://api.ema666.com/Api/userReleaseAllPhone?token=登陆token //url = "http://api.ema666.com/Api/userReleasePhone?token=" + token + "&phoneList=" + phone + ";"; //string res = GetHtml(url); string res = MessageAPI.ClearPhone(token, phone); txt_shifang.Text = res; }
/// <summary> /// 回复TXT /// </summary> /// <param name="message"></param> /// <returns></returns> public ContentResult ReplyTXT(string message) { ContentResult result = new ContentResult(); var sendXml = MessageAPI.GetSendTxtContext(_messageAPI.Message, message); result.Content = MessageAPI.SendEncryptMsg(_messageAPI, sendXml); BaseAPI.Log(result.Content); return(result); }
private void button3_Click(object sender, EventArgs e) { //url = "http://api.ema666.com/Api/userSingleGetMessage?token=" + token + "&itemId=" + itemid + "&phone=" + phone; //url = "http://api.ema666.com/Api/userSingleGetMessage?token=" + token; //string res = GetHtml(url); string res = MessageAPI.GetMessage(token); message = res; txt_message.Text = res; }
private void button2_Click(object sender, EventArgs e) { //指定获取号码:Phone(可以不填写该参数,如空则随机获取新号码) //url = "http://api.ema666.com/Api/userGetPhone?ItemId=" + itemid + "&token=" + token + "&PhoneType=0"; //string res = GetHtml(url); string res = MessageAPI.GetPhone(token); //res = res.Replace(";", ""); phone = res; txt_phone.Text = res; }
public static MessageDal GetMessageDal(this MessageAPI messageAPI) { MessageDal messageDal = new MessageDal(); messageDal.messageAlertId = messageAPI.messageAlertId; messageDal.messageContenu = messageAPI.messageContenu; messageDal.messageDateDebut = messageAPI.messageDateDebut; messageDal.messageDateFin = messageAPI.messageDateFin; messageDal.nomBrasserie = messageAPI.nomBrasserie; return(messageDal); }
public async Task <IActionResult> SendMessage(MessageAPI messageApi) { if (messageApi != null) { try { using (var scope = _scopeFactory.CreateScope()) { var service = scope.ServiceProvider.GetService <IBariQueue>(); var message = new Message(messageApi.Host, messageApi.Description); service.AddQueue(message); } return(Ok()); } catch { return(BadRequest()); } } return(BadRequest()); }
// // GET: /WeiXin/ /// <summary> /// 回调URL /// </summary> /// <returns></returns> public ActionResult VerifyURL(string msg_signature, string timestamp, string nonce, string echostr) { if (Request.HttpMethod == "GET") { return(Content(new MessageAPI(msg_signature, timestamp, nonce).ReplyVerify(echostr))); } else { try { MessageAPI messageAPI = new MessageAPI(new HttpReceive(Request)); WeiXinHelper wxHelper = new WeiXinHelper(messageAPI); return(ReciveMessage(messageAPI, wxHelper)); } catch (Exception ex) { BaseAPI.Log(ex.Source + ":" + ex.Message); return(Content("")); } } }
/// <summary> /// 获取微信返回消息后,需要自行实现逻辑 /// </summary> public abstract ContentResult ReciveMessage(MessageAPI messageAPI, WeiXinHelper wxHelper);
public MessageTest() { InitializeComponent(); itemid = MessageAPI.GetItemID(); }
/// <summary> /// This is a utility method for translating chatter messages into a compatible format for ManyWho. /// </summary> public MessageAPI ChatterMessageToMessageAPI(String chatterBaseUrl, String parentId, ChatterMessage chatterMessage) { MessageAPI message = null; AttachmentAPI attachment = null; message = new MessageAPI(); if (chatterMessage.Attachment != null) { attachment = new AttachmentAPI(); attachment.name = chatterMessage.Attachment.Title; attachment.iconUrl = string.Format("{0}{1}", SettingUtils.GetStringSetting("ManyWho.CDNBasePath"), SalesforceServiceSingleton.CHATTER_DEFAULT_FILE_IMAGE_URL); attachment.description = chatterMessage.Attachment.Description; attachment.type = chatterMessage.Attachment.FileType; attachment.size = chatterMessage.Attachment.FileSize; attachment.downloadUrl = chatterMessage.Attachment.DownloadUrl; // We need to scrub the download url as this url is the REST API that does not work through the browser if (string.IsNullOrWhiteSpace(chatterMessage.Attachment.DownloadUrl) == false && chatterMessage.Attachment.DownloadUrl.IndexOf("servlet.shepherd", StringComparison.OrdinalIgnoreCase) < 0 && chatterMessage.Attachment.DownloadUrl.IndexOf("/services/data/v", StringComparison.OrdinalIgnoreCase) >= 0 && chatterMessage.Attachment.DownloadUrl.IndexOf("/chatter/files", StringComparison.OrdinalIgnoreCase) > 0) { String[] urlParts = chatterMessage.Attachment.DownloadUrl.Split('/'); // Check to make absolutely sure we have enough parts before adapting the url if (chatterMessage.Attachment.DownloadUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase) == true && urlParts.Length >= 8) { // E.g. https://c.cs80.visual.force.com/services/data/v27.0/chatter/files/069250000000ixwAAA/content?versionNumber=1 // Get the file identifier, and make sure it's pointing to the correct instance attachment.downloadUrl = chatterBaseUrl + "/" + urlParts[8]; } else if (chatterMessage.Attachment.DownloadUrl.StartsWith("/services/data", StringComparison.OrdinalIgnoreCase) == true && urlParts.Length >= 6) { // E.g. /services/data/v27.0/chatter/files/069250000000jBeAAI/content?versionNumber=1 // We don't have the full url, so we need to adapt a smaller part attachment.downloadUrl = chatterBaseUrl + "/" + urlParts[6]; } } message.attachments = new List <AttachmentAPI>(); message.attachments.Add(attachment); } message.id = chatterMessage.Id; message.repliedToId = null; if (chatterMessage.Comments != null) { message.commentsCount = chatterMessage.Comments.Total; if (chatterMessage.Comments.Comments != null && chatterMessage.Comments.Comments.Count > 0) { // Convert the child messages over for this message message.comments = this.ChatterMessageToMessageAPI(chatterBaseUrl, message.id, chatterMessage.Comments.Comments); } } if (chatterMessage.MyLike != null) { message.myLikeId = chatterMessage.MyLike.Id; } message.createdDate = DateTime.Parse(chatterMessage.CreatedDate); message.comments = null; if (chatterMessage.Likes != null && chatterMessage.Likes.Likes != null && chatterMessage.Likes.Likes.Count > 0) { message.likerIds = new List <String>(); foreach (ChatterLikeItem chatterLikeItem in chatterMessage.Likes.Likes) { if (chatterLikeItem.User != null) { message.likerIds.Add(chatterLikeItem.User.Id); } } } // The actor will be non-null for root posts, but it's the user for comments if (chatterMessage.Actor != null) { message.sender = this.ChatterUserInfoToWhoAPI(chatterMessage.Actor); } else { message.sender = this.ChatterUserInfoToWhoAPI(chatterMessage.User); } message.text = this.GetMessageText(chatterMessage); return(message); }
public WeiXinHelper(MessageAPI messageAPI) { _messageAPI = messageAPI; }
// // GET: /WeiXin/ /// <summary> /// 自行扩展微信交互回调模式逻辑 /// </summary> /// <param name="messageAPI"></param> /// <param name="wxHelper"></param> /// <returns></returns> public override ContentResult ReciveMessage(MessageAPI messageAPI, WeiXinHelper wxHelper) { var result = new ContentResult(); #region 接收到的消息类型处理 BaseAPI.Log(messageAPI.Message.Element("MsgType").Value); switch (messageAPI.Message.Element("MsgType").Value) { case ReceiveMsgType.Text: var userID = messageAPI.Message.Element("FromUserName").Value; var user = new UserAPI().GetUser(userID); result = wxHelper.ReplyImage("系统不会回复你的", "你以为它会回复你", user.Avatar, "http://www.ysyswenli.net"); break; case ReceiveMsgType.Image: BaseAPI.Log("黄图哥,这张图片不错!"); result = wxHelper.ReplyTXT("黄图哥,这张图片不错!"); break; case ReceiveMsgType.Thumb: break; case ReceiveMsgType.Link: break; case ReceiveMsgType.Location: break; case ReceiveMsgType.Voice: break; case ReceiveMsgType.Music: break; case ReceiveMsgType.Video: break; case ReceiveMsgType.News: break; case ReceiveMsgType.Event: #region 事件类型处理 switch (messageAPI.Message.Element("Event").Value) { case ReceiveMsgType.EventType.SubscribeEvent: result = wxHelper.ReplyTXT("欢迎您!" + messageAPI.Message.Element("FromUserName").Value); break; case ReceiveMsgType.EventType.EnterAgentEvent: result = wxHelper.ReplyTXT("欢迎您!" + messageAPI.Message.Element("FromUserName").Value); break; case ReceiveMsgType.EventType.UnSubscribeEvent: break; case ReceiveMsgType.EventType.ScanEvent: break; case ReceiveMsgType.EventType.ClickEvent: //微信自定义EventKey if (messageAPI.Message.Element("EventKey").Value == "Photo") { result = wxHelper.ReplyImage("test", "test", "http://wx.qlogo.cn/mmhead/Q3auHgzwzM7G71S7KIpSKIhvsnZoTsEw1qbMySdHZJH6rLYUmNKLFw/0", "http://www.ysyswenli.net"); } break; case ReceiveMsgType.EventType.ViewEvent: break; case ReceiveMsgType.EventType.LocationEvent: break; case ReceiveMsgType.EventType.PicSysPhotoEvent: result = wxHelper.ReplyImage("test", "test", "http://wx.qlogo.cn/mmhead/Q3auHgzwzM7G71S7KIpSKIhvsnZoTsEw1qbMySdHZJH6rLYUmNKLFw/0", "http://www.ysyswenli.net"); break; default: break; } #endregion break; } #endregion return(result); }
/// <summary> /// This method allows the user to share the flow app in salesforce with their friends. /// </summary> public MessageAPI PostNotification(INotifier notifier, IAuthenticatedWho authenticatedWho, String oauthToken, ServiceRequestAPI serviceRequest, String endpointUrl, String flowLink, ChatterPostedMessage chatterPostedMessage) { HttpResponseMessage httpResponseMessage = null; HttpClient httpClient = null; MediaTypeFormatter jsonFormatter = null; MultipartFormDataContent multipartFormDataContent = null; ChatterMessage chatterMessage = null; ChatterAttachmentLink chatterAttachmentLink = null; MessageAPI message = null; String chatterBaseUrl = null; String adminEmail = null; if (oauthToken == null || oauthToken.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "OAuthToken cannot be null or blank."); } if (endpointUrl == null || endpointUrl.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "EndpointUrl cannot be null or blank."); } // Grab the values necessary to post the message over to chatter chatterBaseUrl = ValueUtils.GetContentValue(SalesforceServiceSingleton.SERVICE_VALUE_CHATTER_BASE_URL, serviceRequest.configurationValues, true); adminEmail = ValueUtils.GetContentValue(SalesforceServiceSingleton.SERVICE_VALUE_ADMIN_EMAIL, serviceRequest.configurationValues, true); // Now we can create the multipart form we're going to post over to salesforce multipartFormDataContent = new MultipartFormDataContent(); if (flowLink != null && flowLink.Trim().Length > 0) { // We also add the link to the app so the user has it chatterAttachmentLink = new ChatterAttachmentLink(); chatterAttachmentLink.AttachmentType = "Link"; chatterAttachmentLink.Url = flowLink; chatterAttachmentLink.UrlName = "Link to ManyWho Flow"; chatterPostedMessage.Attachment = chatterAttachmentLink; } // We enclose the request in a for loop to handle http errors for (int i = 0; i < SalesforceHttpUtils.MAXIMUM_RETRIES; i++) { try { // Create a new client object httpClient = SalesforceHttpUtils.CreateHttpClient(oauthToken); // Create a new json formatter so the request will be in the right format jsonFormatter = new JsonMediaTypeFormatter(); // Use the JSON formatter to create the content of the chatter post multipartFormDataContent.Add(new ObjectContent <ChatterPostedMessage>(chatterPostedMessage, jsonFormatter), "json"); // Post the message over to chatter httpResponseMessage = httpClient.PostAsync(endpointUrl, multipartFormDataContent).Result; // Check the status of the response and respond appropriately if (httpResponseMessage.IsSuccessStatusCode) { // Grab the chatter message from the post chatterMessage = httpResponseMessage.Content.ReadAsAsync <ChatterMessage>().Result; // Convert it over to a manywho message message = SalesforceSocialSingleton.GetInstance().ChatterMessageToMessageAPI(chatterBaseUrl, null, chatterMessage); // We successfully executed the request, we can break out of the retry loop break; } else { // Make sure we handle the lack of success properly BaseHttpUtils.HandleUnsuccessfulHttpResponseMessage(notifier, authenticatedWho, i, httpResponseMessage, endpointUrl); } } catch (Exception exception) { // Make sure we handle the exception properly BaseHttpUtils.HandleHttpException(notifier, authenticatedWho, i, exception, endpointUrl); } finally { // Clean up the objects from the request BaseHttpUtils.CleanUpHttp(httpClient, null, httpResponseMessage); } } return(message); }