• Partners
  • Email Us
  • Product
    • Channels
      • Voice
      • Email
      • SMS
      • Chat
      • Messenger
      • Omnichannel
    • Features
      • Predictive Dialer
      • VCC Live Pay
      • Outbound IVR
      • Inbound IVR
      • Voicemail Detection
      • Live Dashboards
      • ACD
      • Salesforce Integration
      • Dialogflow
  • Solutions
    • Customer Service
    • Sales Teams
    • Debt Collection
    • Virtual Call Center
  • Pricing
  • Resources
    • Blog
    • Case Studies
    • Ebooks
    • Courses
    • Webinars
    • Information Security
    • Learning Center
    • Developers
  • Company
    • About us
    • Careers
    • News
    • Partners
  • Partners
  • Email Us
+44 208 638 0169
GET STARTED
Developer GuidesDatabase APIExamplesHello World Example
  • Overview
    • About Database API
    • The API location
    • Authentication and Security
    • Testing API
    • Request and Response
    • HTTP Response Codes
  • Examples
    • Hello World Example
    • Advanced Example
    • Web Callback Example
  • Reference
  • Project
    • List projects
    • List project outbound numbers
    • Get project parameters
    • Cloning projects
    • Get quota limits
    • Modify quota limits
  • Database
    • Add field and values
    • Add new value(s) to a field
    • Modify value(s) of a field
    • Delete a value
    • List records
    • Get detailed record information
    • Modify record
    • Modify contact
    • Add record
    • Add disposition
    • Batch record modification
    • Batch disposition modification
    • Add new value to Robinson list
    • Delete from Robinson list resource
  • Statistics
    • Dashboard API
    • Get CDR log
    • Get CDR log for a specified uuid
    • Get Email Log
    • Get voicefile for a specified CDR
    • Get inbound statistics
    • Get call statistics
    • User state log
    • User based statistics
    • User based model
    • Number of available agents in a queue
    • User's Current Status
  • Users
    • List users
    • Add new user
    • List teams
    • List all roles
    • User's Current Status
  • Archiver
    • Get the year and month when no voicefiles were archived
    • List all downloadable voice files in a given month
    • Set a successfully downloaded voicefile as archived
    • Download voice file
  • Campaign Manager
    • Get Database
    • Get Fields
    • Add Customer
    • Modify Customer
Back to Support and Learning Center

Hello World Example

Let’s see how to list, for example, users. Save the following code as ‘vcc-db-api.php’ onto your web server, then open it, change the credential information as required (see: Authentication and Security, and finally save it.

<?php
error_reporting(0);
 
// settings
$customer = 'CUSTOMER';
$password = 'PASSWORD';
 
// build Database API URL
$url = sprintf('https://%s:%s@%s.asp.virtual-call-center.eu', $customer, $password, $customer);
 
// build resource
$resource = $url . '/v2/users';
 
// send HTTP GET request to API and obtain the result
$http_response = file_get_contents($resource);

if ($http_response === false) {
 
    // there is an error
    $last_error = error_get_last();
    echo "Connection error:n" . $last_error['message'] . "nn";
    exit(1);
}
 
// $http_response_header global var contains HTTP response code
list(, $http_response_code) = explode(' ', $http_response_header[0]);
 
// check if HTTP response is OK
if ($http_response_code != 200) {
 
    // there is an error
    echo 'Database API error code: ' . $http_response_code . "nn";
    exit(1);
}
 
echo "Output in JSON format:n" . $http_response . "nn";

// convert json structure into php array
$vcc_users = json_decode($http_response, true);

// print users array
echo "Output as PHP array:n";
var_export($vcc_users);
echo "nn";

Type the URL into any browser (e.g.: http://your.url/vcc-db-api.php), press Enter, and check the output on your screen, which should look similar to the following:

{
    "response": [
        {
            "status": "active",
            "name": "Admin",
            "username": "admin",
            "extension": "4",
            "userid": 4,
            "teams_name": "default_team",
            "group_name": "admin"
        },
        {
            "status": "active",
            "name": "Supervisor",
            "username": "supervisor",
            "extension": "5",
            "userid": 5,
            "teams_name": "default_team",
            "group_name": "supervisor"
        },
        {
            "status": "active",
            "name": "mozmill operator",
            "username": "mozmill_operator",
            "extension": "104",
            "userid": 9,
            "teams_name": "default_team",
            "group_name": "operator"
        }
    ],
    "errors": []
}

Using http://jsonlint.com/ you can convert JSON texts into a readable format, and also validate them. The example code should hopefully be easy to understand, but one section may need some explanation. When you call file_get_contents() function it returns with the HTTP response body and also sets the $http_response_header global variable. It should be checked whether the HTTP response code is 200 or not. If it is not, please check HTTP Response Codes for possible errors.

Note: Do not use this code in production, as the file_get_contents() function is not able to send HTTP POST, PUT and DELETE requests. The above code is only for demonstration.

Back to Support and Learning Center

Comments

Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.


There are no comments yet.

Click here to cancel reply.

Please note that by clicking on the Submit button, you agree to a member of VCC Live team contacting you with business offers. You can find detailed information on how we can establish contact with you in our Privacy Policy

  • Channels
    • Voice
    • Email
    • SMS
    • Chat
    • Messenger
    • Omnichannel
  • Main Features
    • Call Center Software
    • Predictive Dialer
    • VCC Live Pay
    • Outbound IVR
    • Inbound IVR
    • Voicemail Detection
    • Live Dashboards
    • ACD
    • Salesforce Integration
    • Dialogflow
  • Solutions
    • Customer Service
    • Sales Teams
    • Debt Collection
    • Virtual Call Center
  • Resources
    • Blog
    • Case Studies
    • Ebooks
    • Courses
    • Webinars
    • Information Security
    • Learning Center
    • Developers
    • Download
  • Company
    • About us
    • Careers
    • News
    • Partners
https://vcc.live/wp-content/uploads/2019/07/iso-cert-1.png https://vcc.live/wp-content/uploads/2019/07/iso-cert-2.png https://vcc.live/wp-content/uploads/2019/07/iso-cert-3.png
Social Media
https://vcc.live/wp-content/uploads/2019/07/linkedin.svg https://vcc.live/wp-content/uploads/2019/07/twitter.svg https://vcc.live/wp-content/uploads/2019/07/facebook-1.svg https://vcc.live/wp-content/uploads/2019/07/instagram-1.svg
Call us
Hungary
+36 19996400
UK
+44 2086380169
Germany
+49 3021782516
Poland
+48 123950886
Romania
+40 31706167
USA
+1 3024988337
Hungary
+36 19996400
UK
+44 2086380169
Germany
+49 3021782516
Poland
+48 123950886
Romania
+40 31706167
USA
+1 3024988337
  • Privacy Policy
  • Cookie Policy
  • Legal Statement
  • General Terms of Agreement
  • Magyar nyelvű jogi dokumentumok