Example code

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


// 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

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

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

// close curl resource

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";