PHP code example of usystems / webling-api-php

1. Go to this page and download the library: Download usystems/webling-api-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

usystems / webling-api-php example snippets


$api = new Webling\API\Client('https://demo.webling.ch','MY_APIKEY');

$response = $api->get('member/123');

if ($response->getStatusCode() < 400) {
    var_dump($response->getData());    // returns the parsed JSON
    var_dump($response->getRawData()); // returns the raw response string
}

$response = $api->put('/member', $data);
$response = $api->post('/member', $data);
$response = $api->delete('/member/123');

$options = [
    'connecttimeout' => 5, // connection timeout in seconds
    'timeout' => 10, // transfer timeout
    'useragent' => 'My Custom User-Agent' // custom user agent
];
$api = new Webling\API\Client('https://demo.webling.ch','MY_APIKEY', $options);

// create a cache object
$client = new Webling\API\Client('https://demo.webling.ch','MY_APIKEY');
$adapter = new Webling\CacheAdapters\FileCacheAdapter([
    'directory' => './webling_cache'
]);
$cache = new Webling\Cache\Cache($client, $adapter);

// get single object
$member = $cache->getObject('member', 506);

// get binary data of object
$cache->getObjectBinary('member', 506, $member['properties']['Mitgliederbild']['href']);

// get multiple objects
$cache->getObjects('member', [506, 507, 508]);

// get object lists
$cache->getRoot('membergroup');

// check for updates and renew cache
$cache->updateCache();

// clear the whole cache
$cache->clearCache();