I'm new to C#. I want to send message from a desktop app using C#, for that I bought an API from a mobile company (Telenor). According to their documents first I'll have to get authentication ID by sending request to this URL (https://telenorcsms.com.pk:27677/corporate_sms2/api/auth.jsp?msisdn=xxxx&password=xxx) and it gives me response in XML format like this:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Auth_request</command>
<data>Session ID</data>
<response>OK</response>
</corpsms>
Now I need the session ID which is in <data>
node, to use further for sending message like (https://telenorcsms.com.pk:27677/corporate_sms2/api/sendsms.jsp?session_id=xxxx&to=923xxxxxxxxx,923xxxxxxxxx,923xxxxxxxxx&text=xxxx&mask=xxxx).
I tried many methods to bring out the session ID and use it but have got no idea, how to do it. its my code:
WebClient client = new WebClient ();
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = client.OpenRead ("https://telenorcsms.com.pk:27677/corporate_sms2/api/auth.jsp?msisdn=xxxx&password=xxx");
StreamReader reader = new StreamReader (data);
StreamReader objreadr = new StreamReader(data);
string s = reader.ReadToEnd();
You can use Linq to Xml
var sessionid = XDocument.Parse(s).Descendants("data").First().Value;