Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using System.Net;
- using System.Xml.Linq;
- // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
- namespace SMSAPI.Controllers
- {
- [Route("api/Message")]
- public class SMSController : Controller
- {
- // GET: api/values
- [HttpGet]
- public IEnumerable<string> Get()
- {
- return new string[] { "val222ue1", "value2" };
- }
- [HttpPost]
- public IActionResult SendMessage()
- {
- string username = "52929055";
- string password = "AWQU4nRE";
- string tophonenumberwithcountrycode = "+4552929055";
- string fromMax11Char = "NPS";
- string theMessage = "Hej";
- string pathtouse = "https://api.suresms.com/Script/SendSMS.aspx?login=" + username + "&password=" + password + "&to =" +tophonenumberwithcountrycode + "&from =" +fromMax11Char + "&Text =" +WebUtility.UrlEncode(theMessage);
- /* Call the Path */
- WebRequest wrGETURL = WebRequest.Create(pathtouse);
- WebResponse res = wrGETURL.GetResponseAsync().Result;
- XDocument xDoc = XDocument.Load(res.GetResponseStream());
- return new NoContentResult();
- }
- // GET api/values/5
- [HttpGet("{id}")]
- public string Get(int id)
- {
- return "value";
- }
- // PUT api/values/5
- [HttpPut("{id}")]
- public void Put(int id, [FromBody]string value)
- {
- }
- // DELETE api/values/5
- [HttpDelete("{id}")]
- public void Delete(int id)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement