VIBER + SMS API

DecisionTelecom Viber + SMS API le permite enviar y recibir mensajes comerciales de Viber hacia y desde cualquier país del mundo a través de API, y si el mensaje de Viber no se entrega a un cliente, se reenviará y entregará como un mensaje SMS normal. Cada mensaje se identifica mediante una identificación aleatoria única, por lo que los usuarios siempre pueden verificar el estado de un mensaje utilizando un punto final determinado.

La API de Viber + SMS utiliza HTTPS con clave de acceso que se utiliza como autorización de la API. Las cargas útiles de solicitud y respuesta se formatean como JSON mediante la codificación UTF-8.

Autorización API: clave de acceso Base64.

Póngase en contacto con su administrador de cuenta para obtener una clave API.

Autorización

Autenticación básica

Example:

$userHashKey = 'User Hash Key provided by your account manager';
$ch = curl_init('https://web.it-decision.com/v1/api/send-viber');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$userHashKey");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestParams)); // 
$requestParams - raquest array with correct data 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
$result = curl_exec($ch); 
curl_close($ch);

Enviar mensaje de Viber

https://web.it-decision.com/v1/api/send-viber
{
    "source_addr": "Custom Company", 						
    "destination_addr": 8882222200,							
    "message_type":106, 									
    "text":"Message content", 								
    "text_sms":"SMS message content", // add this parameter: if, in the event of non-delivery via Viber, it is necessary to resend transactional message via SMS  
    "image":"https://yourdomain.com/images/image.jpg", 		
    "button_caption":"Join Us", 							
    "button_action":"https://yourdomain.com/join-us",   	
    "source_type":2, 										
    "callback_url":"https://yourdomain.com/viber-callback",
    "validity_period":40
}

Parámetros

source_addr:

<= 20 chars - from whom the message

destination_addr:

<= 20 chars - to whom the message

message_type (Type of message sent):

106 only text (convenient for transactional messages)

108 text+image+button (convenient for promotional messages)

206 only text (2Way)*(convenient for promotional messages)

208 text+image+button (2Way)* (convenient for promotional messages)

text:

<= 1000 chars - text of Viber message

text_sms:

<= 70 chars for UCS-2 (16-bit) and <= 160 chars for Latin - alternative SMS text if Viber message is not delivered (only for transactional messages)

image (Correct URL with image for promotional message with button caption and button action):

jpg or jpeg (mime type is image/jpeg), maximum resolution 400x400 pixels

png (mime type is image/png), maximum resolution 400x400 pixels

button_caption:

<= 30 chars - button caption

button_action:

Correct URL for transition when you press the button

source_type (Message sending procedure):

promotion message (the message can be with text, picture and button) - 1

transactional message (text message) - 2

callback_url:

Correct URL for message status callback

validity_period:

TTL (Time to live) allows the sender to limit the life time of a message. In case the message did not get the status "delivered" before the time ended, the message will not be charged and will not be delivered to the user. In case no TTL was provided (no "ttl" parameter) Viber will try to deliver the message for

up to 1 day.

promotion message - min TTL 40 seconds max TTL 21600 seconds (6 hours)

transactional message - min TTL 40 seconds max TTL 21600 seconds (6 hours)

transactional message + SMS - TTL only 40 seconds

Response:

{
    "message_id":429	
}

Valores:

message_id:

Sent message ID

Get message from a user for 2Way messages:

For 2way messages ITD Viber system will send callbacks with each user's message. The tracking data content will be sent by the client according to the tracking data in the last message which was received on the Viber client’s side.

The responce implies that the API user has a callback url for this messages.

Response:

{
    "message_token": 44444444444444,
    "phone_number": "972512222222",
    "time": 2121212121,
    "message": 
    {
        "text": "a message to the service",
        "tracking_data": "tracking_id:100035"
    }
}

Valores

message_token:

client response message token

phone_number:

client phone number

time:

client response message time

message:

text:

client response message text

tracking_data:

tracking_id: The id of the message to which the client is responding

Recibir mensaje de Viber

https://web.it-decision.com/v1/api/receive-viber
{
    "message_id":429	
}

Parámetros

message_id:

The ID of the message whose status you want to get (for the last 5 days)

{
	"message_id":429, 			
	"status":1, 				
	"sms_message_id":36478, 	
	"sms_message_status":2		
}

Valores

message_id:

The ID of the message whose status you want to get (for the last 5 days)

status:

Current Viber message status

sms_message_id:

SMS message ID (if available, only for transactional messages)

sms_message_status:

SMS message status (if available, only for transactional messages)

Estados de los mensajes de Viber

sent0

delivered

1

error

2

rejected

3

undelivered

4

pending

5

unknown

20

Estados de los mensajes SMS

delivered2

undeliverable

5

expired

3

Errores

Name Too Many Requests

message

Rate limit exceeded

code

0

status

429

NameInvalid Parameter: [param_name]

message

Empty parameter or parameter validation error

code

1

status

400

NameInternal server error

message

The server encountered an unexpected condition which prevented it from fulfilling the request

code

2

status

500

NameTopup balance is required

message

User balance is empty

code

3

status

402

Ejemplo de Viber + SMS

curl --location --request POST 'https://web.it-decision.com/v1/api/receive-viber' \
--header 'Authorization: Basic api key' \
--header 'Content-Type: application/json' \
--data-raw '{"source_addr": "Custom Company","destination_addr": 380636111112,"message_type":106,"text":"Message content","text_sms":"SMS message content","image":"https://yourdomain.com/images/image.jpg","button_caption":"Join Us", "button_action":"https://yourdomain.com/join-us","source_type":2,"callback_url":"https://yourdomain.com/viber-callback","validity_period":3600
}'

Last updated