Functions

POST

Include the helper functions ‘Post’ for POST-Requests:

<?php

 function Post(array $data) {
    $url = 'http://[url-to-crmplus]/webservice.php';

    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, array('Accept: application/json'));
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($handle, CURLOPT_POST, 1);
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    $response = curl_exec($handle);
    curl_close($handle);

    return json_decode($response, true);
}

GET

Include the helper functions ‘Get’ for GET-Requests:

<?php

function Get(array $data) {
    $url  = 'http://[url-to-crmplus]/webservice.php';
    $url .= '?' . http_build_query($data, '', '&');

    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, array('Accept: application/json'));
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0);
    $response = curl_exec($handle);
    curl_close($handle);

    return json_decode($response, true);
}