46elks T-shirt challenge

Try the 46elks API,
get a T-shirt!

To participate do the following:

Send us an SMS with your T-shirt size to +46766868334 using the 46elks API. Send the message from "Tshirt".

How?

  1. Create a 46elks account
  2. Choose your preferred programming language:
curl https://api.46elks.com/a1/sms \
  -u API_USERNAME:API_PASSWORD \
  -d to=+46766868334 \
  -d message="My t-shirt size: L. Fit: curvy." \
  -d from=Tshirt
$sms = array(
  "to" => "+46766868334",
  "message" => "My t-shirt size: L. Fit: curvy.",
  "from" => "Tshirt"
);

$USER = "API_USERNAME";
$PASS = "API_PASSWORD";

$url  = "https://api.46elks.com/a1/sms";
$auth = 'Authorization: Basic '.
base64_encode($USER.':'.$PASS)."\r\n".
"Content-type: application/x-www-form-urlencoded\r\n";

$context = stream_context_create(array(
  'http' => array(
    'method' => 'POST',
    'header'  => $auth,
    'content' => http_build_query($sms),
    'timeout' => 10
)));

file_get_contents($url, false, $context);
import requests

requests.post('https://api.46elks.com/a1/sms',
  auth = ('API_USERNAME', 'API_PASSWORD'),
  data = {
    'to': '+46766868334',
    'message': "My t-shirt size: L. Fit: curvy.",
    'from': 'Tshirt'
  }
)
require 'net/http'

uri = URI('https://api.46elks.com/a1/SMS')
req = Net::HTTP::Post.new(uri)
req.basic_auth 'API Username', 'API Password'
req.set_form_data(
  :from => 'Tshirt',
  :to => '+46766868334',
  :message => 'My t-shirt size: L. Fit: curvy.'
)

res = Net::HTTP.start(
    uri.host,
    uri.port,
    :use_ssl => uri.scheme == 'https') do |http|
  http.request req
end

puts res.bodyusing System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace elktest {
    class Program {

        public static string user = "API Username";
        public static string pwd = "API Password";
        private static HttpClient client;
        static void Main(string[] args)

        {
            Task.Run(async() = > {
                using(client = new HttpClient()) {
                    client.BaseAddress = new Uri("https://api.46elks.com");

                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
                        "Basic",
                        Convert.ToBase64String(
                            System.Text.ASCIIEncoding.ASCII.GetBytes(
                                string.Format("{0}:{1}", user, pwd))));

                    var content = new FormUrlEncodedContent(new[] {
                        new KeyValuePair < string, string > ("from", "Tshirt"),
                        new KeyValuePair < string, string > ("to", "+46766868334"),
                        new KeyValuePair < string, string > ("message", "My t-shirt size: L. Fit: curvy."),
                    });

                    HttpResponseMessage response = await client.PostAsync("/a1/SMS", content);
                    response.EnsureSuccessStatusCode();
                    var result = await response.Content.ReadAsStringAsync();
                }
            }).Wait();
        }
    }
}const https = require('https')
const querystring = require('querystring')

const username = 'API-username'
const password = 'API-password'
const auth_str = username + ':' + password
const postFields = {
  to:      "+46766868334",
  message: "My t-shirt size: L. Fit: curvy.",
  from:    "Tshirt",
}

const key = new Buffer(auth_str).toString('base64')
const postData = querystring.stringify(postFields)

const options = {
  hostname: 'api.46elks.com',
  path:     '/a1/SMS',
  method:   'POST',
  headers:  {
    'Authorization': 'Basic ' + key
  }
}

const callback = (response) => {
  var result = ''
  response.on('data', (chunk) => {
    result += chunk
  })

  response.on('end', () => {
    console.log(result)
  })
}

var request = https.request(options, callback)
request.write(postData)
request.end()import HTTPotion.base

authdata = [basic_auth: {'API-Username',
                         'API-Password'}]

request = %{
            "from"    => "Tshirt",
            "to"      => "+46766868334",
            "message" => "My t-shirt size: L. Fit: curvy."
           }

request_data = URI.encode_query(request)

HTTPotion.start
HTTPotion.post("https://api.46elks.com/a1/SMS",[body: request_data , ibrowse: authdata])
  1. Login to your account
  2. Locate your API-credentials.
  3. Send the SMS!
Anna and Niina holding a t-shirt

T-shirts are available in sizes XS-4XL.
You can choose between a curvy and a straight fit.

46elks t-shirt with curvy fit 46elks t-shirt with straight fit
46elks logo

Automating telephony with code is easy using the 46elks API. With just a few lines of code you can automate sending and receiving SMS and MMS. You can also make and receive phone calls! 📞

Got questions? Contact us.