AddressBook

Ask tech team
From QuickBlox Developers (API docs, code samples, SDK)
Jump to: navigation, search

Contents

Summary

A set of REST API requests to work with QuickBlox Address Book.


Need to know information

Before using the Users module please read the following:



AddressBook API

Requests and Responses

URL HTTP Verb Action Description Success HTTP Status Code
/address_book.json POST Upload address book 200
/address_book.json GET Retrieve address book 200
/address_book/registered_users.json GET Retrieve already registered contacts/users 200



Upload address book

Upload address book. Using this API you can actually do 4 things:

  • Upload fresh address book (overwrite the previous one)
  • Upload new contacts
  • Update existing contacts

Parameters

Param Required Type Value Example Description
contacts Yes Hash {'name':'Frederic Cartwright', 'phone': '8879108395'} Contains array of contact hashes. Each contact can contain 3 keys: name: contact name. String (required only for create/update), min 1 max 255 symbols. phone: contact phone. String (required), min 10 max 15 symbols. destroy: used in a case of contact destroy. Integer (not required, possible value 1).
force No Integer 1 Defines force rewrite mode. If set 1 then all previous contacts for device context will be replaced by new ones.
udid No String D337E8A4-80AD-8ABA-9F5D-579EFF6BACAB User's device identifier. If specified all operations will be in this context. Max length 64 symbols. If not - it means a user has one global address book across all his devices.


Request

curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
-d '{"contacts": [{"name":"Barbra Nader","phone":"4657393241"},{"name":"Kristi Pollich","phone":"6502272571"}], "force": 1, "udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"}'' \
https://api.quickblox.com/address_book.json

Response

{
  "deleted" : 0,
  "rejected" : {
    "5" : [ "Invalid fields set" ],
    "6" : [ "Length of 'phone' field should be min: 10 and max: 15." ],
    "8" : [ "Length of 'name' field should be min: 1 and max: 255." ]
  },
  "created" : 4,
  "updated" : 1
}


Retrieve address book

Retrieve all uploaded address book contacts.

Parameters

Param Required Type Value Example Description
udid No String D337E8A4-80AD-8ABA-9F5D-579EFF6BACAB User's device identifier. If specified all operations will be in this context. Max length 64 symbols. If not - it means a user has one global address book across all his devices.


Request

curl -X GET \
-H "Content-Type: application/json" \
-H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
https://api.quickblox.com/address_book.json

Response

[ 
  {
    "phone" : "6278336065",
    "name" : "Frederic Cartwright"
  },
  {
    "phone" : "72783360345",
    "name" : "John Samson"
  }  
]


Retrieve already registered contacts/users

Retrieve QuickBlox users who already registered from your address book.

Parameters

Param Required Type Value Example Description
udid No String D337E8A4-80AD-8ABA-9F5D-579EFF6BACAB User's device identifier. If specified all operations will be in this context. Max length 64 symbols. If not - it means a user has one global address book across all his devices.
compact No Integer 1 Specifies whether to return only users' id+phone fields. If 0 - will return all user's fields.


Request

curl -X GET \
-H "Content-Type: application/json" \
-H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
https://api.quickblox.com/address_book/registered_users.json

Response

{
  "items": [
    {
      "user": {
        "id": 87,
        "full_name": "John Partizan",
        "email": "john@domain.com",
        "login": "Kitty",
        "phone": "7665891",
        "website": "http://partizan.com",
        "created_at": "2012-03-20T08:47:34Z",
        "updated_at": "2012-05-09T08:25:33Z",
        "last_request_at": "2012-05-08T13:07:37Z",
        "external_user_id": 158,
        "facebook_id": "1346987743",
        "twitter_id": "545878645453",
        "twitter_digits_id": 23487743,
        "blob_id": null,
        "custom_data": null,
        "user_tags": "hello, world, hey"
      }
    },
  ...
  ]
}