Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Mvc;
  6. using System.Net;
  7. using System.Xml.Linq;
  8.  
  9. // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
  10.  
  11. namespace SMSAPI.Controllers
  12. {
  13.     [Route("api/Message")]
  14.     public class SMSController : Controller
  15.     {
  16.         // GET: api/values
  17.         [HttpGet]
  18.         public IEnumerable<string> Get()
  19.         {
  20.             return new string[] { "val222ue1", "value2" };
  21.         }
  22.  
  23.         [HttpPost]
  24.         public IActionResult SendMessage()
  25.         {
  26.             string username = "52929055";
  27.             string password = "AWQU4nRE";
  28.             string tophonenumberwithcountrycode = "+4552929055";
  29.             string fromMax11Char = "NPS";
  30.             string theMessage = "Hej";
  31.  
  32.             string pathtouse = "https://api.suresms.com/Script/SendSMS.aspx?login=" + username + "&password=" + password + "&to =" +tophonenumberwithcountrycode + "&from =" +fromMax11Char + "&Text =" +WebUtility.UrlEncode(theMessage);
  33.  
  34.             /* Call the Path */
  35.             WebRequest wrGETURL = WebRequest.Create(pathtouse);  
  36.             WebResponse res = wrGETURL.GetResponseAsync().Result;
  37.             XDocument xDoc = XDocument.Load(res.GetResponseStream());
  38.            
  39.             return new NoContentResult();
  40.         }
  41.         // GET api/values/5
  42.         [HttpGet("{id}")]
  43.         public string Get(int id)
  44.         {
  45.             return "value";
  46.         }
  47.  
  48.  
  49.         // PUT api/values/5
  50.         [HttpPut("{id}")]
  51.         public void Put(int id, [FromBody]string value)
  52.         {
  53.         }
  54.  
  55.         // DELETE api/values/5
  56.         [HttpDelete("{id}")]
  57.         public void Delete(int id)
  58.         {
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement