4.1.4 Contacts - mobile
Contacts
URL: /contacts.ashx
Parameter | Description |
---|---|
l | Login - login of SIP account |
p | Password - password of sip account |
cl | Contacts list - a list of contacts in JSON format. An example of what this format should look like is provided below. |
sm | Synchronization method - contact list synchronization method.
|
rp | Response method - the parameter determines the method in which the response should be received. Accepted parameters:
|
Code will be received in response. The list of possible codes is below.
Kod | Description |
---|---|
200 | OK |
400 | Incorrect parameters - one of the parameters has not been provided |
403 | Invalid HTTP method - only POST method accepted |
404 | Invalid JSON format |
405 | Server side error |
406 | The login and/or password are incorrect |
cURL Request Example
curl --location --globoff --request POST 'https://xxxxxxxxx/emcd/contacts.ashx?l=piotr&p=wmhwrs2jfo&cl=[{%22id%22%3A0%2C%22name%22%3A%22Piotr%20Tokarczyk%22%2C%22numbers%22%3A[{%22number%22%3A%224866666666%22%2C%22mark%22%3A0%2C%22os%22%3A%22and%22}]}%2C{%22id%22%3A1%2C%22name%22%3A%22Wieslaw%20Zgodny%22%2C%22numbers%22%3A[{%22number%22%3A%224855555555%22%2C%22mark%22%3A0%2C%22os%22%3A%22and%22}]}]&sm=update&rp=http' \ --header 'User-Agent: vippie;ios;1.2.3' \ --header 'Content-Type: text/plain' \ --header 'Authorization: Basic YW5kOmFuZDJhMzJkaW0=' \ --header 'X-VIPPIE-DEVICE-ID: ff66fc693846285d' \ --header 'X-VIPPIE-DEVICE-NAME: iPhone8,1' |
---|
Sample JSON data exchange format for the address book - update and full methods.
[ { "id": 1, "name": "Sebastian Chojnacki", "users": [ { "name": "sebac", "mark": 1, "os": "ios" } ], "numbers": [ { "number": 48555555555, "mark": 1, "os": "ios" }, { "number": 48666666666, "mark": 1, "os": "and" } ], "emails": [ { "email": "alias@domena.com", "mark": 1, "os": "ios" }, { "email": "alias@domena.pl", "mark": 0, "os": "and" } ] }, { "id": 2, "name": "Jan Kowalski", "users": [ { "name": "kow1", "mark": 1, "os": "ios" }, { "name": "kow2", "mark": 1, "os": "bb" } ], "numbers": [ { "number": 48555145212, "mark": 0, "os": "" } ] } ]
There is no limit of numbers for a given contact. The numbers must be written in the international format - i.e. with the country code.
Sample JSON data exchange format for the address book - remove method.
[3,4,5]
Sample JSON format for the verify method.
{ "acc": 120, "anc": 125, "vcc": 10, "vnc": 12, "vuc": 2 }
The verify method is used to verify the number of contacts between the local(device) and global(server) database. The JSON object includes the following fields:
- acc - the number of all contacts
- anc - number of all numbers for all contacts(contacts can have multiple numbers)
- vcc - number of all vippie* contacts
- vnc - the sum of all numbers for all vippie* contacts
- vuc - the number of all vippie* ID for all vippie* accounts
*-vippie contact - is a person who is using our app and we have him in our contact list, such contact can have a multiple numbers registered
After sending all the above parameters to the server, we will receive code 200 as the "cl" parameter, which means that all information is consistent. When the server returns the code 413, it means that there are differences in the global database and contacts should be synchronized using the full method.
The list of RCS users. Reply from the server
Response method http
In response, a token will be sent, e.g.: c9bc64e8-f7e4-4439-9dbe-6d9b8180f1a1
The token is then sent in a request to the /contacts.ashx method with the 'sm' parameter with the 'check' value:
l=1510049&p=KJu92Nz1ysBPE&cl=c9bc64e8-f7e4-4439-9dbe-6d9b8180f1a1&sm=check
In case of an error, the following code will be returned:
Kod | Description |
---|---|
453 | token expired, you need to send the contacts again |
454 | pending, you must resend the token after a few seconds (e.g. 5sec) |
In other cases, JSON with a list of RCS users will be returned.
{"add":{"users":[{"id":56,"u":"chrisogl1","l":"1129392","os":"and"}]}}
When sending a list of contacts larger than 300, the list should be divided into smaller packages (e.g. 300 items each) and sent one by one. After sending the first package, we receive a token, we send the token to check whether there is already a JSON list, if so, after receiving it, we send the next package. We repeat the procedure until the entire book has been sent. During this time, you should update the contact list in the UI and show the RCS users every time the JSON list arrives.
Response method sms
After sending the list to the server, a separate process will return in the form of an SMS or a few text messages (depending on the number of contacts) a list of contacts that already exist in the system as users.
SMS content for phone contacts
SIPLINK_COMMAND : Contacts add : {"phones":[{"id":1,"n":48502159212,"l":1000000,"os":"ios"},{"id":2,"n":48502159211,"l":1000010,"os":"and"}]}
SIPLINK_COMMAND : Contacts del : {"phones":[{"id":3,"n":48502159200},{"id":4,"n":48502159201}]}
Blocking a contact
This method allows you to block selected contacts. To block a given contact or contacts, please send the following parameters:
Parameters
Parameter | Description |
---|---|
l | Login - login of SIP account |
p | Password - password of sip account |
method | setBlock - block selected contacts |
params | the list of sip logins to block, example: [ "100247", "100057" ] |
Return value
code | Description |
---|---|
200 | OK - the list of logins has been saved, at the same time the blocked logins will receive the SIPLINK_COMMAND message with the following content SIPLINK_COMMAND : Contacts add : {"blocked":"1000200"} with information about which user added me to their blocked list. |
400 | Incorrect parameters - one of the parameters was not provided |
500 | Internal server error |
Unblocking a contact
Parameters
Parameter | Description |
---|---|
l | Login - login of the SIP account |
p | Password - password of the SIP account |
method | delBlock - unblocking selected contacts |
params | the list of sip accounts to be unlocked, example: [ "100247", "100057" ] |
Return value
Code | Description |
---|---|
200 | OK - the list of logins has been saved, at the same time the unlocked logins will receive the SIPLINK_COMMAND message with the following content: SIPLINK_COMMAND : Contacts add : {"unblocked":"1000200"} with information about which user unblocked me from their blocked list. |
400 | Incorrect parameters - one of the parameters was not provided |
500 | Internal server error |
Odczyt zablokowanych kontaktów
Parameter | Description |
---|---|
l | Login - login of the SIP account |
p | Password - password of the SIP account |
method | getBlock - downloads the list of blocked contacts and the list of users who blocked me |
cURL Request Example
curl --location --request POST 'https://xxxxxxxxx/emcd/contacts.ashx?l=piotr&p=wmhwrs2jfo&method=getBlock' \ --header 'User-Agent: vippie;ios;1.2.3' \ --header 'Content-Type: text/plain' \ --header 'Authorization: Basic YW5kOmFuZDJhMzJkaW0=' \ --header 'X-VIPPIE-DEVICE-ID: ff66fc693846285d' \ --header 'X-VIPPIE-DEVICE-NAME: iPhone8,1' |
---|
Return value
{ "in": [ "login1", "login2", "login3" ], "out": [ "login4", "login5", "login6" ] }
where:
- in - contains a list of SIP logins that have been blocked by a given user
- out - contains a list of SIP logins that have blocked a given user