-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.fs
36 lines (27 loc) · 1.1 KB
/
main.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Example tested with F# Compiler for F# 4.5 (Open Source Edition)
//
open System.Text
open System.IO
open System.Net
// HTTPS API Endpoint: https://secure.smslink.ro/sms/gateway/communicate/index.php
// HTTP API Endpoint: http://www.smslink.ro/sms/gateway/communicate/index.php
let url = "https://secure.smslink.ro/sms/gateway/communicate/index.php"
let req = HttpWebRequest.Create(url) :?> HttpWebRequest
req.ProtocolVersion <- HttpVersion.Version10
req.Method <- "POST"
//
// Get your SMSLink / SMS Gateway Connection ID and Password from
// https://www.smslink.ro/get-api-key/
//
let postBytes = Encoding.ASCII.GetBytes("connection_id=...My Connection ID ...&password=... My Connection Password ...&to=07xyzzzzzz&message=Test Message")
req.ContentType <- "application/x-www-form-urlencoded";
req.ContentLength <- int64 postBytes.Length
let reqStream = req.GetRequestStream()
reqStream.Write(postBytes, 0, postBytes.Length);
reqStream.Close()
let resp = req.GetResponse()
let stream = resp.GetResponseStream()
let reader = new StreamReader(stream)
let html = reader.ReadToEnd()
printfn "%s" html