Example code

The code below retrieves the latest publisher news. Of course don’t forget to authenticate and use the correct publisher ID. Your publisher ID can be fetched using the “GET /publishers” resource or in your account (“My account” -> “Account details”).

Click here to see an example how to retrieve transactions from the Daisycon Platform.

Please also check out these code samples on Github:
Github Example 1
Github Example 2

Example PHP code – Getting the latest publisher news

<?php

// publisher
$publisher_id 1234;

// service
$url 'https://services.daisycon.com/publishers/' $publisher_id  '/news';

// authentication
$username 'username';
$password 'password';

// initialize curl resource
$ch curl_init();

// set the http request authentication headers
$headers = array( 'Authorization: Basic ' base64_encode$username ':' $password ) );

// set curl options
curl_setopt($chCURLOPT_URL$url);
curl_setopt($chCURLOPT_HTTPHEADER$headers);
curl_setopt($chCURLOPT_RETURNTRANSFERtrue); 

// execute curl
$response curl_exec($ch);

// check http code
$code curl_getinfo($chCURLINFO_HTTP_CODE);

// close curl resource
curl_close($ch);

if ($code == 200)
{
    // json decode reponse
    $news json_decode($response);

    // display response
    foreach ($news as $news_item)
    {
        echo 'id: ' $news_item->id "\n";
        echo 'name: ' $news_item->title "\n\n";
    }
}