API

Message hub for business

Mobica Ltd. is the first Bulgarian company which delivers business messages via Viber, Telegram, Messenger.

These new services are complimented by reliable SMS and HLR

Contact Sales

API general overview

API - based on HTTP protocol. Communication implemented on client–server basis.

The platform accepts GET/POST requests. It returns GET request with DLR (message status).

GET requests from the user must be URL encoded.

Security and confidentiality:

  1. The platform uses HTTPS protocol
  2. There is an IP restriction for every user.
  3. When passing each request, username and password are validated.
  4. Option for a VPN connection.

In case some of the above-mentioned verifications are not passed successfully – request for SMS will be denied and the client notified. In case of a malicious attack, IP of the sender will be blocked.

HTTP SMS sending:

  1. Please contact Mobica support (support@mobica.bg) in order to receive username and password. They will be your identifier when sending a short text message.
  2. Your account starts with a small amount of money for testing. After money’s depletion, it is necessary to top-up your account in order to use the service.
  3. You must configure IP addresses that you will be sending requests from.

Parameters:

Parameter Description Obligatory
user Your username yes
pass Your pasword yes
phone Receiver’s number must contain country code (for example: 359 888888888). One request can contain more than one mobile phone number using a comma (,) to separate the numbers. yes
message Message text. The length of the text with Latin symbols is up to 160 characters. When the text is in Cyrillic (Unicode), the limit is up to 67 characters. If the symbols exceed this number,they are paid with an additional short text message. yes
from Message sender (Sender ID). There is a limit up to 11 symbols, if your route allows an alpha sender. If not provided, a default will be used. Your client is set by an administrator. no
route Number of package.The message will be sent from (integer). If you have more than one package. If not provided, it will go via the package that is configured by default. no
idd Unique identification number of your short text message. It serves to receive a dynamic status (string). NO
(YES for DLR)
smartCut When text length exceeds one short text message, the network processes it as two or more text messages Smart cut attempts not to cut words in the text. Activation occurs with random monetary value. no
toDate Future date format (YYYY-mm-dd h:min) on which the SMS will be delivered. If not provided, SMS is instant. no
Table 1

Response codes:

# Description Status
1 Successfully accepted request 1004
2 Invalid Phone Number 1006
3 Invalid schedule data 1007
4 Invalid Request Format 1008
5 Money in your account have ran out 1117
6 No value for obligatory field is set 1120
7 Request sent from unauthorized IP address 1121
Table 2

JSON POST REQUEST

REQUEST URL:

https://gate.mobica.bg/send.php

REQUIRED HEADERS:

accept: application/json

content-type: application/json

single message

{
 "user":" < your username >",
 "pass":"< your password >",
 "phone":[
  "< phone >"
],
 "sms":{
  "message":"< sms text >",
  "from":"< sender >",
  "idd":"< dlr id >",
  "route":"< your route >",
  "priority":"0",
  "smartCut":"1",
 },
}

MULTIPLE MESSAGE

{
 "user":" < your username >",
 "pass":"< your password >",
 "phone":[
  "idd1":"< phone1 >",
  "idd2":"< phone2 >",
.
.
.
  "iddN":"< phoneN >",
],
 "sms":{
  "message":"< sms text >",
  "from":"< sender >",
  "route":"< your route >",
  "priority":"0",
  "smartCut":"1",
 },
}

RESPONSE (Table2)

{
 "status": "1004" ,
 "desc": "message accepted" ,
}

EXAMPLE PHP:

<?php $settings['username']='your username'; $settings['password']='your password'; $settings['route']='your default route'; $settings['from']='your default sender'; $settings['smartcut']='1';//active $settings['urlApi']='https://gate.mobica.bg/send.php'; function sendSMSJson($phones,$message,$dlrId=false, $route=false,$perority=0){ global $settings; $data=array(); $data['user']=$settings['username']; $data['pass']=$settings['password']; if(is_array($phones)){ $data['phones']=$phones; }else{ $data['phones'][]=$phones;//$phones can be string or array from phones } $data['sms']['message']=$message; $data['sms']['from']=$settings['from']; $data['sms']['route']=intval($route)>0 ? intval($route) : $settings['route']; $data['sms']['smartCut']=$settings['smartcut']; $data['sms']['prirority']=intval($perority)>0 ? 1:0; if(!empty($dlrId)){ $data['sms']['idd']=$dlrId; } $data['sms']=(object)$data['sms']; $data=(object)$data; $json=json_encode($data); $headers=array("accept: application/json", "content-type: application/json"); $ch=curl_init($settings['urlApi']); $finalOptArray=array( CURLOPT_POST => true ,CURLOPT_POSTFIELDS => $json ,CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_HTTPHEADER =>$headers ,CURLOPT_TIMEOUT => 15); curl_setopt_array($ch,$finalOptArray); $response=curl_exec($ch); $error=curl_error($ch); curl_close($ch); return $response; //if(response==1004) all is OK } ?>

GET REQUEST

REQUEST URL – SINGLE MESSAGE:

https://gate.mobica.bg/send.php?user=<'your user name'>&pass=<'your password'>&phone=359888888888&message=test%20message&from=test&route=<'my route'>

REQUEST URL – MULTIPLE MESSAGE:

https://gate.mobica.bg/send.php?user=<'your user name'>&pass=<'your password'>&phone=359888888888,359888888889,359888888887,359888888886&message=test%20message&from=test&route=<'my route'>

RESPONSE

1004 //if all is OK

EXAMPLE PHP:

<?php $settings['username']='your username'; $settings['password']='your password'; $settings['route']='your default route'; $settings['from']='your default sender'; $settings['smartcut']='1';//active $settings['urlApi']='https://gate.mobica.bg/send.php'; function sendSMSGet($phone,$message,$dlrId=false, $route=false,$perority=0){ global $settings; $url = $settings['urlApi']."?user=".urlencode($settings['username']). "&pass=".urlencode( $settings['password']). "&phone=".urlencode($phone). "&message=".urlencode($message). (!empty($settings['from'])?"&from=".urlencode($settings['from']):""). (!empty($settings['route'])?"&route=".urlencode($settings['route']):""). (!empty($dlrId) ? "&idd=".urlencode($dlrId) :""); $ch=curl_init($url); curl_setopt_array($ch,array( CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_TIMEOUT => 15 )); $response=curl_exec($ch);//1004 if all is ok $error=curl_error($ch); curl_close($ch); return $response; } ?>

POST REQUEST

REQUEST URL

https://gate.mobica.bg/send.php

RESPONSE

1004 //if all is OK

EXAMPLE PHP:

<?php $settings['username']='your username'; $settings['password']='your password'; $settings['route']='your default route'; $settings['from']='your default sender'; $settings['smartcut']='1';//active $settings['urlApi']='https://gate.mobica.bg/send.php'; function sendSMSPost($phones,$message,$dlrId=false, $route=false,$perority=0){ global $settings; if(is_array($phones)){ $phones=implode(',',$phones); } $data="user=".urlencode($settings['username']). "&pass=".urlencode($settings['password']). "&phone=".urlencode($phones). "&message=".urlencode($message). (!empty($settings['from'])?"&from=".urlencode($settings['from']):""). (!empty($settings['route'])?"&route=".$settings['route']:""). (!empty($dlrId) ? "&idd=".urlencode($dlrId) : ""); $ch=curl_init($settings['urlApi']); curl_setopt_array($ch,array( CURLOPT_POST => true ,CURLOPT_POSTFIELDS => $data ,CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_TIMEOUT => 15 )); $response=curl_exec($ch);//1004 if all is ok $error=curl_error($ch); curl_close($ch); return $response; } ?>

DLR (Delivery Report)

DLR is an automatic report that shows the status of each valid SMS. Please provide valid URL address to Mobica support. We send DLR by GET request to your link.

DLR request sample:

<'your URL'>?id=15552&phone=359888888888&chanel=SMS&status=1000&desc=Delivered&date=2014-09-21 09-10-55

Parameters:

Parameter Description Obligatory
id Identification number of your SMS request. Corresponds to parameter “idd“in your SMS request. yes
phone GSM number that the message is sent to. yes
chanel The service used to send the message (sms, viber, telegram) yes
status Service status. yes
desc Description for sms status yes
date Date and time of the message. (yyyy-mm-dd hh:mm:ss) yes
Table 3

DLR status:

# Description Code
1 Message successfully delivered. 1000
2 Operator you are sending request to is not authorized. 1113
3 There is a missed word in the message. 1116
4 No money. 1117
5 You are repeating a message sent within the last 10 minutes. 1118
6 Message pending 1203
7 Message expired (after 24 hours pending) 1204
8 Message not sent to the end user. 1205
9 Message status is unknown. 1206
Table 4

SMPP SMS sending:

  1. Please contact Mobica support (support@mobica.bg) in order to receive username and password. They will be your identifier when sending a short text message.
  2. Your account starts with a small amount of money for testing. After money’s depletion, it is necessary to top-up your account in order to use the service.
  3. You must configure IP addresses that you will be sending requests from.

OUR SMPP SERVER SETTINGS:

IP: 85.217.170.42

Port: 8056

RESPONSE:

# Description Code
1 No value for obligatory field is set 0x000000C3
2 Request sent from unauthorized IP address: 0x00000100
3 Money in your account have ran out 0x00000100
4 Successfully accepted request: 0x000000FF
Table 5

DLR STATUS REQUEST:

# Description Code
1 Successfully delivered 0x02
2 Rejected 0x08
3 The message is waiting to be sent. 0x01
4 The message is not delivered and 24 hours have passed since its sending. 0x03
5 The message is not sent to the end user. 0x05
6 The message status is unknown. 0x07
Table 6

HLR

HLR (Home Location Register) is an online service that provides information about home country and network of a mobile subscriber, validity verification, current location, ported number identification.

  1. Please contact Mobica support (support@mobica.bg) for username and password. They will be your identifier when sending HLR.
  2. Your account will be loaded with a small amount of money for testing. After its depletion, it is necessary to topup your account, in order to use the service.
  3. You must configure IP addresses that you will be sending requests from.
  4. The GET request must have the following format:

    https://gate.mobica.bg/numberlookup.php?user=<'your user name'>&pass=<'your password'>&number=359888888888&reference=12121&url=<'url get hlr request'>

    OR

    https://gate.mobica.bg/numberlookup.php?user=<'your user name'>&pass=<'your password'>&number=359888888888&reference=12121&email=<'your email'>

Request parameters:

Parameter Description Obligatory
user Your username yes
pass Your pasword yes
number Receiver’s number must contain country code (for example: 359 888888888). One request can contain more than one mobile phone number using a comma (,) to separate the numbers. yes
URL A valid URL address must be indicated, that will be used for accepting the requests' statuses. Example: http(s)://www.yourdomain.com/callback no
reference Unique identification number of your HLR. It serves to receive a dynamic status (integer). no
email Number of package through which the message will be sent (integer). no
Table 7

Response codes:

# Description Status
1 Successfully accepted request 1004
2 No value for obligatory field is set 1120
3 Request sent from an unauthorized IP address 1121
4 Money in your account have ran out 1117
5 Invalid Phone Number 1006
Table 8

Status in Callback URL Request:

Parameter Description Obligatory
NUMBER Requested number in the HLR request yes
REFERENCE Reference parameter from the sent request for HLR yes
STATUS One of the statuses in Table 10 yes
REASON When the status is not „Delivered“, the reason will be specified (Table 11). yes
TIMESTAMP Indication of the time when the server operator has received the request. The format isYYYYMMDDHHMMSS. Example: 20120501083055 yes
IMSI IMSI of the number. no
NETWORKCODE Operator’s network code. The Network code contains MCC (the country code is the first three digits) and MNC (code of the operator is the last 2 digits). Example: 20404 no
OPERATOR Country and operator. Example: (BULGARIA)GLOBUL no
COUNTRYCODE Literal index of the operator's country. Example: bg no
MSC MSC (Commutation center) to which the number is registered at the time of the verification. It starts with the country's code and operator’s code, where the subscriber's latest registration is. If it is roaming, the first digits show where he/she is located (country and mobile operator are identified). no
Table 9

Status in Callback URL Request:

# Description RESPONSE
1 The number is valid. 1000
2 The number is invalid. 1205
3 The request is rejected. 1207
4 The time of the request has run out. 1204
5 Unknown status. 1206
Table 10

Reason status table:

Description RESPONSE
Absent subscriber (network cannot contact subscriber) 1
Handset memory exceeded 2
Equipment protocol error 3
Equipment not equipped with short-message capability 4
Unknown service centre (destination MSC) 5
Service centre congestion (Too much inbound traffic at the destination network) 6
Invalid SME address 7
Subscriber is not a SC subscriber (Number belongs to a different destination network, but HLR is not updated) 8
Unknown subscriber (IMSI is unknown in the HLR) 9
Illegal subscriber (The mobile station failed authentication) 10
Teleservice not provisioned (Mobile subscription identified by the MSISDN number does not include the short message service. Might happen, because the number/subscriber has been blocked) 11
Illegal equipment (IMEI check failed, blacklisted or not whitelisted) 12
Call barred (Operator barred the MSISDN number) 13
Facility not supported (VLR in the PLMN does not support MT short message service) 14
Subscriber busy for MT short messages 15
System failure 16
Message waiting list at HLR is full 17
Data missing 18
Unexpected data value 19
Resource limitation at peer / destination network 20
TCAP error (Duplicate invoke ID) 21
TCAP error (Service not supported) 22
TCAP error (Mistyped parameter) 23
TCP error (Resource Limit) 24
TCAP error (TCAP initiating release) 25
TCAP error (Unexpected response from peer) 26
TCAP error (Service completion failure) 27
TCAP error (No response from peer. No response from the end user, might be because user is out of coverage, or there is some issue with his/her phone) 28
TCAP error (Invalid response received) 29
Unidentified subscriber. Unable to indentify the subscriber. Might be due to invalid number 30
Service temporary not available 31
Illegal error code 32
Network timeout 33
Operation Barred (From the MNO) 34
Delivery failure 35
cError in MSHLR 36
PLMN system failure 37
HLR system failure 38
VLR system failure 39
Controlling MSC failure (Error in the MSC where the user is located) 40
Visited MSC failure (Error in the visited MSC) 41
MNP other operator not allowed (MSISDN is ported, delivery via this SMSC is not permitted) 42
Subscriber temporarily unreachable (While roaming) 43
Message store busy 44
SME Interface busy 45
Closed user group rejection 46
Network failure 47
Deferred Delivery (Message has not been delivered and is part of a deferred delivery schedule) 48
Error getting route 49
Rejected Destination 51
Rejected - Unknown Reason 52
Rejected due to a routing issue 53
Rejected due to a blocking issue 54
Rejected - no price 55
Rejected - not enough credit 56
Rejected due to spam filter 57
Rejected due to flooding 58
UNKNOWN TCType,SMS 59
UNKNOWN TCType,SRI 60
UNKNOWN 61
Failure due to submission towards AA19 destination 62
Sent to SME, but unable to confirm 63
Replaced at the SMSC 64
Quality service not available 65
Error in SMSC 66
Rejected by operator due to validity period expiration 67
Intermediate state notification; message has not been delivered yet, due to a phone-related problem, but is being retried 68
Cannot determine whether this message has been delivered, or it has failed, due to a lack of final delivery state information from the operator. 69
Specific content is not permitted on the network / shortcode 70
Subscriber cannot receive adult content because of a parental lock 71
Failure due to ported combinations being unreachable. 72
Roaming subscriber. 73
Failure due to ported combinations being blocked for client (Client has been blacklisted from the ported destination). 74
Abort from HLR 75
Source address is blacklisted or not supported 76
Operation barred 77
Facility not provided 78
Invalid absolute validity period 79
SMS center received 80
Invalid PDU format 81
Local Cancel (Temporary problem / Lost reach) 82
Rejected due to duplication 83
Maximum connection reached 84
Information not available 85
Message waiting list is full 86
Short term denial 87
Message replaced by SMSC 89
Congestion at subscriber 90
Service rejected 91
Error in SME 92
Remote procedure error 93
Connection rejected by SME 94
SM deleted by sender 95
SM deleted by SMSC Admin 96
Absent subscriber IMSI detached 97
SMS malformed 98
DCS inconsistency 99
Maximum submission attempt reached 100
Maximum time to live for message reached 101
No response from SME 102
Maximum submission attempt reached (finalised before validity period expiration) 103
Max TTL for message reached (finalised when validity period expired) 104
Portability error 105
Canceled at SMSC 106
Table 11

Example PHP for HLR sending via HTTPS:

GET REQUEST

<?php $url = "https://gate.mobica.bg/numberlookup.php"; $url.="?user=".urlencode($username). "&pass=".urlencode($password). "&number=".urlencode($phones). "&url=".urlencode($myURL). ($reference!=0 ? "&reference=".urlencode($reference):""); $ch=curl_init($url); curl_setopt_array($ch,array( CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_TIMEOUT => 15 )); $response=curl_exec($ch); $error=curl_error($ch); curl_close($ch); ?>

POST REQUEST

<?php $url = "https://gate.mobica.bg/numberlookup.php"; if(is_array($phones)){ $phones=implode(',',$phones); } $data="?user=".urlencode($username). "&pass=".urlencode($password). "&number=".urlencode($phones). "&url=".urlencode($myURL). ($reference!=0 ? "&reference=".urlencode($reference):""); $ch=curl_init($url); curl_setopt_array($ch,array( CURLOPT_POST => true ,CURLOPT_POSTFIELDS => $data ,CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_TIMEOUT => 15 )); $response=curl_exec($ch); $error=curl_error($ch); curl_close($ch); ?>

Check DLR status:

PARAMETER Description OBLIGATORY
user Your username YES
pass Your pasword YES
idd Unique identification number of your short text message. It serves to receive a dynamic status (string). NO
(YES for DLR)

REQUEST URL

https://gate.mobica.bg/checkDLR.php?user=<'username'>&pass=<'password'>&idd=<'user_idd_ref_one_sms'>

RESPONSE

1000 //SMS is delivered

EXAMPLE PHP:

<?php $settings['username']='your username'; $settings['password']='your password'; $settings['urlApi']='https://gate.mobica.bg/checkDLR.php'; function sendSMSPost($dlrId){ global $settings; $data="user=".urlencode($settings['username']). "&pass=".urlencode($settings['password']). (!empty($dlrId) ? "&idd=".urlencode($dlrId) : ""); $ch=curl_init($settings['urlApi'] ?: 'https://gate.mobica.bg/checkDLR.php'); curl_setopt_array($ch,array( CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_TIMEOUT => 15 )); $response=curl_exec($ch);//1000 if delivered $error=curl_error($ch); curl_close($ch); return $response; } ?>

User Money Check:
Money are checked and updated in your account every 10 min

PARAMETER Description OBLIGATORY
user Your username YES
pass Your pasword YES

REQUEST URL

https://gate.mobica.bg/check_money.php?user=<'username'>&pass=<'password'>

RESPONSE

10 Лв. //Your money

EXAMPLE PHP:

<?php $settings['username']='your username'; $settings['password']='your password'; $settings['urlApi']='https://gate.mobica.bg/check_money.php'; function sendSMSPost($dlrId){ global $settings; $data="user=".urlencode($settings['username']). "&pass=".urlencode($settings['password']); $ch=curl_init($settings['urlApi'] ?: 'https://gate.mobica.bg/check_money.php'); curl_setopt_array($ch,array( CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_TIMEOUT => 15 )); $response=curl_exec($ch);//1004 if all is ok $error=curl_error($ch); curl_close($ch); return $response; } ?>

VIBER SEND MESSAGE

  1. Please contact Mobica support (support@mobica.bg) in order to receive username and password.They will be your identifier when sending a short text message.
  2. Your account starts with a small amount of money for testing. After money’s depletion, it is necessary to top-up your account in order to use the service.
  3. You must configure IP addresses that you will be sending requests from.
  4. If you wish to have a sender id, please contact our support: support@mobica.bg
    Note: To be eligible you need to have at least 200,000 messages sent per month, of which 60,000 to be delivered. If this minimum is not reached, you can still have your channel by paying minimum monthly fee 300 EUR
    Viber safe its right to cancel the channel.

JSON POST REQUEST

REQUEST URL:

https://gate.mobica.bg/send.php

REQUIRED HEADERS:

accept: application/json

content-type: application/json

Request parameters:

Parameter Description Obligatory
user Your username yes
pass Your pasword yes
phones (array of object) The list of phone numbers. With one message request the customer can send up to 1000 phone numbers yes
viber (object) Parameters text, buttonCaption + buttonAction and image make Viber Service Message content. There are 4 possible combinations of Viber Service Message content:
  • text only
  • image only
  • text + button
  • text + button + image
yes
viber.tag Free text, reports can be generated based on tags. (e.g. "campaign_name") Tags are used in analytics GUI to filter out specific traffic based on tag. no
viber.text The Viber Service Message text. Text length can be up to 1000 characters. VIBER text can be sent alone, without button or image no
viber. expiry_text Relevant for iOS version of Viber application (iPhone users only).This is the text that will be displayed if Viber Service Message expires. If not provided, it will automatically be filled with default text. no
viber.validity_period_sec TTL value in seconds (range - 15 to 86400). If the Viber Service message can’t be delivered within given seconds, we will send an SMS message as a fallback. no
viber. button_text A textual writing on the button. Maximum length is 30 characters.The VIBER button can be sent only if Viber Service Message contains text no
viber. button_url The link of button action. no
viber. image_url The URL address of image sent to end user. The VIBER image can be sent alone or together with text and button. no
viber. is_promotional Indicates if content is of promotional character no
viber.sms_text This text will be received via SMS if Viber message is not delivered. no
viber.idd Unique identification number of your Viber message. It serves to receive a dynamic status (string). no
(YES for DLR)
Table 12

EASY INTEGRATION (with default SMS API)

SINGLE MESSAGE DATA

{
 "user":" < your username >",
 "pass":"< your password >",
 "phone":[
  "< phone >"
],
 "viber":{
  "text":"< Example text >",
  "image_url":"< valid image url >",
  "button_url":"https://mobica.bg",
  "button_text":"click me",
  "idd":"unique id",
  "is_promotional":"0",
  "validity_period_sec":"600",
  "sms_text":"< sms text >",
 },
}

MULTIPLE MESSAGE

{
 "user":" < your username >",
 "pass":"< your password >",
 "phone":[
  "idd1":"< phone1 >",
  "idd2":"< phone2 >",
.
.
.
  "iddN":"< phoneN >",
],
 "viber":{
  "text":"< Example text >",
  "image_url":"https://mobica.bg/app/templates/default/imgs/Mobiceviber.JPG",
  "button_url":"https://mobica.bg",
  "button_text":"click me",
  "is_promotional":"0",
  "validity_period_sec":"600",
  "sms_text":"< sms text >",
 },
}

Response

{
 "status": "1004" ,
 "desc": "message accepted" ,
}

Response codes

# Description STATUS
1 Message accepted 1004
2 This messenger can not support image 1012
3 This messenger can not support button 1013
4 This messenger can not support button 1018
5 User not active 1105
6 Inactive user 1106
7 You don't have HLR permission 1107
8 No money 1117
9 Flood 1118
10 IP not allowed 1121

Status in Callback URL Request:

# Description STATUS
1 Waiting for transmit 1003
2 Successfully accepted request 1004
3 Rejected 1005
4 Invalid Phone Number 1006
5 Invalid Request Format 1008
6 Messenger text is empty 1010
7 Messenger text must be under 1000 and over 3 symbols 1011
8 Button text length is large 1014
9 SMS text must be under 160 and over 3 symbols 1015
10 Invalid image source 1016
11 Button url is invalid 1017
12 Flood 1018
13 Cannot support button without text 1019
14 SMS text is required 1020
15 Money in your account have ran out 1117
16 Messenger not allowed 1119
17 No value for obligatory field is set 1120
18 Request sent from unauthorized IP address 1121
19 Phone number is in blacklist 1209

Example php

<?php $settings['username']='your username'; $settings['password']='your password'; $settings['route']='your default route'; $settings['tag']='your default tag'; $settings['is_promotional']=0; $settings['validity_period_sec']=600; $settings['urlApi']='https://gate.mobica.bg/send.php'; function sendViber($phones,$viber_message,$sms_text, $image_url,$button_url,$button_text=false,$dlrId=false){ global $settings; $data=array(); $data['user']=$settings['username']; $data['pass']=$settings['password']; if(is_array($phones)){ $data['phones']=$phones; }else{ $data['phones'][]=$phones;//$phones can be string or array from phones } $hasMessage=false; $hasImage=false; $hasButton=false; if(!empty($viber_message)){ $data['viber']['text']=$viber_message; $hasMessage=true; } if(!empty($image_url)){ $data['viber']['image_url']=$image_url; $hasImage=true; } if(!empty($button_url)){ if($hasMessage){ $data['viber']['button_url']=$button_url; $data['viber']['button_text']=!empty($button_text) ? $button_text : 'click me'; $hasButton=true; }else{ throw new \Exception('Invalid viber message format. Show table 12 - >viber'); } } if($hasMessage && $hasImage && !$hasButton){ throw new \Exception('Invalid viber message format. Show table 12 ->viber'); } if(!$hasMessage && !$hasImage && !$hasButton){ throw new \Exception('Invalid viber message format. Show table 12 ->viber'); } $data['viber']['idd']='unique id'; $data['viber']['tag']=isset($settings['tag']) && !empty($settings['tag']) ? $settings['tag'] : 'test'; $data['viber']['is_promotional']=isset($settings['is_promotional']) && intval($settings['is_promotional'])>0 ? 1 : 0; $data['viber']['validity_period_sec']=isset($settings['validity_period_sec']) && intval($settings['validity_period_sec'])>0 ? intval($settings['validity_period_sec']) : 600; $data['viber']['sms_text']=$sms_text; if(!empty($dlrId)){ $data['viber']['idd']=$dlrId; } $data['viber']=(object)$data['viber']; $data=(object)$data; $json=json_encode($data); $headers=array("accept: application/json", "content-type: application/json"); $ch=curl_init($settings['urlApi']); $finalOptArray=array( CURLOPT_POST => true ,CURLOPT_POSTFIELDS => $json ,CURLOPT_RETURNTRANSFER => true ,CURLOPT_FOLLOWLOCATION => false ,CURLOPT_HTTPHEADER =>$headers ,CURLOPT_TIMEOUT => 15); curl_setopt_array($ch,$finalOptArray); $response=curl_exec($ch); $error=curl_error($ch); curl_close($ch); return $response; //if(response==1004) all is OK }

FULL INTEGRATION (with SMS API)

SINGLE MESSAGE DATA

{
 "user":" < your username >",
 "pass":"< your password >",
 "phone":[
  "< phone >"
],
 "viber":{
  "text":"< Example text >",
  "image_url":"< valid image url >",
  "button_url":"https://mobica.bg",
  "button_text":"click me",
  "idd":"unique id",
  "is_promotional":"0",
  "validity_period_sec":"600",
 },
 "sms":{
  "message":"<sms text >",
  "from":"< sender >",
  "idd":"< dir id >",
  "route":"< your route >",
  "prirority":"0",
  "smartCut":"1",
 },
}

MULTIPLE MESSAGE

{
 "user":" < your username >",
 "pass":"< your password >",
 "phone":[
  "idd1":"< phone1 >",
  "idd2":"< phone2 >",
.
.
.
  "iddN":"< phoneN >",
],
 "viber":{
  "text":"< Example text >",
  "image_url":"https://mobica.bg/app/templates/default/imgs/Mobiceviber.JPG",
  "button_url":"https://mobica.bg",
  "button_text":"click me",
  "is_promotional":"0",
  "validity_period_sec":"600",
  "sms_text":"Ako ima problem s otkrivaneto na pot",
 },
 "sms":{
  "message":"<sms text >",
  "from":"< sender >",
  "route":"< your route >",
 },
}