Editar a entrada de Telefone
Editar uma entrada com um número de telefone.
Authorizations
Seção intitulada “Authorizations ”Parameters
Seção intitulada “ Parameters ”Path Parameters
Seção intitulada “Path Parameters ”ID do telefone
Identificador do telefone
Request Body required
Seção intitulada “Request Body required ”The updated phones resource
Phones list by group
object
Número de telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
String which will be send back to your endpoint. E.g. it can be usable to pass your system message id.
Example generated
{ "phone": "example", "a": "example", "b": "example", "c": "example", "d": "example", "e": "example", "callback_data": "example"}Responses
Seção intitulada “ Responses ”Phones resource updated
Phones list by group
object
JSON-LD ID
JSON-LD type
ID do telefone
Número de telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
String which will be send back to your endpoint. E.g. it can be usable to pass your system message id.
Timestamp de quando o usuário se inscreveu link
Timestamp when user was unsubscribed by a link
Unsubscribe reasons:
- 1 - I never subscribed
- 2 - Too many messages
- 3 - I am not interested
- 4 - Content is incomprehensible
- 5 - I don’t like your company
- 6 - Other
Example
{ "@context": { "hydra": "http://www.w3.org/ns/hydra/core#" }}Phones list by group
object
ID do telefone
Número de telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
Dados da coluna do telefone
String which will be send back to your endpoint. E.g. it can be usable to pass your system message id.
Timestamp de quando o usuário se inscreveu link
Timestamp when user was unsubscribed by a link
Unsubscribe reasons:
- 1 - I never subscribed
- 2 - Too many messages
- 3 - I am not interested
- 4 - Content is incomprehensible
- 5 - I don’t like your company
- 6 - Other
Example generated
{ "id": 1, "phone": "example", "a": "example", "b": "example", "c": "example", "d": "example", "e": "example", "callback_data": "example", "subscribed_at": 1, "unsubscribed_at": 1, "unsubscribe_reason": 1}Invalid input
Client ID or API key isn’t active or invalid!
Account isn’t activated. Please wait or contact to support!
Resource not found
The request was well-formed but was unable to be followed due to semantic errors
O endereço IP foi bloqueado temporariamente, pois durante um curto período de tempo foram enviadas várias solicitações com credenciais inválidas. Aguarde e tente mais tarde.
Code Samples
#!/usr/bin/env bashcurl -X PUT https://api.lox24.eu/phones/12344 \ -H 'Content-Type: application/json' \ -H 'X-LOX24-AUTH-TOKEN: 1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx' \ -d '{ "phone": "+93701234567", "a": "Mr. ", "b": "Smith ", "c": "2020-02-23 18:00", "d": "12.34", "e": "restaurant Blue Oyster"}'using Newtonsoft.Json;using Newtonsoft.Json.Linq;using System;using System.IO;using System.Net;using System.Text;
namespace Lox24.Api{ class client { static void Main() { string key = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"; string url = "https://api.lox24.eu/phones/12344";
var data = new { phone = "+93701234599" };
string postdata = JsonConvert.SerializeObject(data);
Console.WriteLine("Post data: {0}", postdata);
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ReadWriteTimeout = 100000; httpWebRequest.ContentType = "application/json; charset=utf-8"; httpWebRequest.Accept = "application/json"; // or application/ld+json httpWebRequest.Method = "POST"; httpWebRequest.KeepAlive = true; httpWebRequest.Headers.Add("X-LOX24-AUTH-TOKEN", key); httpWebRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(postdata); streamWriter.Flush(); streamWriter.Close(); } try { using (HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse()) {
if(resp.StatusCode == HttpStatusCode.Created) { Console.WriteLine("Success:{0} {1}", (int)resp.StatusCode, "phone resource updated"); } else { Console.WriteLine("Error: wrong response code {0} on update phone", (int)resp.StatusCode); }
Stream respStream = resp.GetResponseStream(); using (StreamReader sr = new StreamReader(respStream, Encoding.UTF8)) { string responseText = sr.ReadToEnd(); Console.WriteLine("responseText : {0}", responseText); } }
} catch (System.Net.WebException ex) { var webResponse = ex.Response as System.Net.HttpWebResponse; Console.WriteLine("Error:{0}", webResponse.StatusCode);
switch (webResponse.StatusCode) { case HttpStatusCode.BadRequest: // 400 Console.WriteLine("Error:400 Invalid input"); break; case HttpStatusCode.Unauthorized: // 401 Console.WriteLine("Error:401 Client ID or API key isn't active or invalid!"); break; case HttpStatusCode.Forbidden: // 403 Console.WriteLine("Error:403 Account isn't activated. Please wait or contact to support!"); break; case HttpStatusCode.NotFound: // 404 Console.WriteLine("Error:404 Resource not found"); break; case HttpStatusCode.InternalServerError: // 500 case HttpStatusCode.BadGateway: //502 case HttpStatusCode.ServiceUnavailable: // 503 case HttpStatusCode.GatewayTimeout: // 504 Console.WriteLine("System error! Please contact to LOX24 support!"); break; } } } }package main
import ( "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http")
func main() {
url := "https://api.lox24.eu/phones/12344" method := "PUT"
payload := map[string]string{ "phone": "+93701234567", "a": "Mr. ", "b": "Smith ", "c": "2020-02-23 18:00", "d": "12.34", "e": "restaurant Blue Oyster", }
jsonPayload, _ := json.Marshal(payload)
client := &http.Client{}
req, err := http.NewRequest(method, url, bytes.NewBuffer(jsonPayload)) if err != nil { log.Fatal(err) }
req.Header.Add("X-LOX24-AUTH-TOKEN", "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx") req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req) if err != nil { log.Fatal(err) }
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body) if err != nil { log.Fatal(err) }
switch res.StatusCode { case 200: fmt.Println(string(body)) case 400: fmt.Println("Error: code = 400 - Invalid input") case 401: fmt.Println("Error: code = 401 - Client ID or API key isn't active or invalid!") case 403: fmt.Println("Error: code = 403 - Account isn't activated. Please wait or contact to support!") case 404: fmt.Println("Error: code = 404 - Resource not found") default: fmt.Printf("Error: code = %d\n", res.StatusCode) }}package eu.lox24.doc.phones;
import org.json.JSONObject;
import java.io.IOException;import java.net.HttpURLConnection;import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.time.Duration;
public class PutPhonesItem {
public static void main(String[] args) {
var key = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"; var id = "12344"; var url = "https://api.lox24.eu/phones/" + id;
var json = new JSONObject(); json.put("phone", "+93701234567"); json.put("a", "Mr. "); json.put("b", "Smith "); json.put("c", "2020-02-23 18:00"); json.put("d", "12.34"); json.put("e", "restaurant Blue Oyster");
var putData = json.toString();
System.out.println("Put data: " + putData);
var httpRequest = HttpRequest.newBuilder(URI.create(url)) .timeout(Duration.ofMillis(100000)) .setHeader("Content-Type", "application/json; charset=utf-8") .setHeader("Accept", "application/json") // or application/ld+json .setHeader("X-LOX24-AUTH-TOKEN", key) .PUT(HttpRequest.BodyPublishers.ofString(putData)) .build();
var client = HttpClient.newBuilder() .version(HttpClient.Version.HTTP_1_1) // Http 1.1 clients are kept alive be default .build();
try { var httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString());
if (httpResponse.statusCode() == HttpURLConnection.HTTP_OK) { System.out.println("Success:" + httpResponse.statusCode() + " " + "phones resource updated");
JSONObject parsed = new JSONObject(httpResponse.body());
parsed.keys().forEachRemaining(jsonKey -> System.out.println(jsonKey + ":" + parsed.get(jsonKey))); } else {
System.out.println("Error: wrong response code " + httpResponse.statusCode() + " on update phone");
switch (httpResponse.statusCode()) {
case HttpURLConnection.HTTP_BAD_REQUEST: // 400 System.out.println("Error:400 Invalid input"); break; case HttpURLConnection.HTTP_UNAUTHORIZED: // 401 System.out.println("Error:401 Client ID or API key isn't active or invalid!"); break; case HttpURLConnection.HTTP_FORBIDDEN: // 403 System.out.println("Error:403 Account isn't activated. Please wait or contact to support!"); break; case HttpURLConnection.HTTP_NOT_FOUND: // 404 System.out.println("Error:404 Resource not found"); break; case HttpURLConnection.HTTP_INTERNAL_ERROR: // 500 case HttpURLConnection.HTTP_BAD_GATEWAY: //502 case HttpURLConnection.HTTP_UNAVAILABLE: // 503 case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: // 504 System.out.println("System error! Please contact to LOX24 support!"); break; }
}
} catch (IOException | InterruptedException e) { e.printStackTrace(); } }}const host = 'api.lox24.eu';const token = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx";
var postObj = { phone: '+93701234567', a: 'Mr. ', b: 'Smith', c: '2020-02-23 18:00', d: '12.34', e: 'restaurant Blue Oyster'};
var postdata = JSON.stringify(postObj);
const https = require('https');const options = { hostname: host, path: '/phones/1234', method: 'PUT', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Content-Length': postdata.length, 'X-LOX24-AUTH-TOKEN': token }}
const req = https.request(options, res => { if (res.statusCode == 200) { console.log("Success: code = 200 - phone resource created"); res.on('data', d => { process.stdout.write(d) }) } else if (res.statusCode == 400) { console.log("Error: code = 400 - Invalid input"); } else if (res.statusCode == 401) { console.log("Error: code = 401 - Client ID or API key isn't active or invalid!"); } else if (res.statusCode == 402) { console.log("Error: code = 402 - There are not enough funds on your account!"); } else if (res.statusCode == 403) { console.log("Error: code = 403 - Account isn't activated. Please wait or contact to support!"); } else { console.log("Error: code = " + res.statusCode ); }})
req.on('error', error => { console.error(error)})req.write(postdata);req.end();<?php
$uri = 'https://api.lox24.eu/phones/12344';
$token = '1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx';
$body = [ 'phone' => '+93701234567',];
if(!$body = json_encode($body)) { die('JSON encoding error!');}
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_URL => $uri, CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => [ "X-LOX24-AUTH-TOKEN: {$token}", 'Accept: application/json', // or application/ld+json 'Content-Type: application/json', ], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,]);
$response = curl_exec($curl);$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);curl_close($curl);
$data = json_decode($response, JSON_OBJECT_AS_ARRAY);
if(200 === $code) { echo 'Success: response data = ' . var_export($data, true);} else { echo "Error: code = {$code}, data = " . var_export($data, true);}import jsonimport requests
token = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"
phone_id = "12344"
url = f'https://api.lox24.eu/phones/{phone_id}'
data = { "phone": "+93701234567", "a": "Mr. ", "b": "Smith ", "c": "2020-02-23 18:00", "d": "12.34", "e": "restaurant Blue Oyster",}
headers = { 'Accept': 'application/json', # or application/ld+json 'Content-Type': 'application/json', 'X-LOX24-AUTH-TOKEN': token,}
try: # timeout is 100 seconds res = requests.put(url, headers=headers, timeout=100) if res.status_code != 200: res.raise_for_status() else: print(f'Success: code = {res.status_code} - phones resource updated') print("Response: ", json.dumps(res.json(), indent=4))
except requests.HTTPError: if res.status_code == 400: print("Error:400 Invalid input") elif res.status_code == 401: print("Error: code = 401 - Client ID or API key isn't active or invalid!") elif res.status_code == 403: print("Error: code = 403 - Account isn't activated. Please wait or contact to support!") elif res.status_code == 404: print("Error:404 Resource not found") elif res.status_code in (500, 502, 503, 504): print("System error! Please contact to LOX24 support!") else: print(f"Error: code {res.status_code}") print(json.dumps(res.json(), indent=4))