Lenguaje "Go"

Enviar mensajes – REST API – JSON

[code]
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://api.labsmobile.com/json/send"

    payload := strings.NewReader("{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}")

    req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
    req.Header.Add("Cache-Control", "no-cache")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
[/code]

Consulta de créditos – REST API – JSON

[code]
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://api.labsmobile.com/json/balance"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
    req.Header.Add("Cache-Control", "no-cache")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
[/code]

Enviar mensajes – HTTP/GET

[code]
import "net/http"

resp, err := http.Get("http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message")
if err != nil {
	// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
[/code]

Consulta de créditos – HTTP/GET

[code]
import "net/http"

resp, err := http.Get("http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]")
if err != nil {
	// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
[/code]

Llámanos