heartbeat/sdk-partner-api

There is no license information available for the latest version (1.0.0) of this package.

Heartbeat Partner API SDK

1.0.0 2018-12-06 18:45 UTC

This package is auto-updated.

Last update: 2021-06-28 12:51:17 UTC


README

Access the Heartbeat Content Hub Partner APIs with this easy to use PHP SDK.

Build Status Latest Stable Version Test Coverage Maintainability Total Downloads License

Installation

In order to use this library composer is required.

composer require heartbeat/sdk-partner-api

Usage

Examples how to use the Heartbeat SDK. For each request you need a valid Client object holding the access key:

$client = new Client('ACCESS_TOKEN');

Events

Usage examples to get the latest events and display informations:

// create the client object with the access token
$client = new \Heartbeat\Client('MY_ACCESS_TOKEN');

// foreach events and display related data including pois
foreach (\Hearbeat\EventDate::findAll($client) as $date) {

    // display the event date related informations
    echo $date->start_timestamp;
    echo $date->end_timestamp;

    // display the related event for this date:
    echo $date->event->title;
    echo $date->event->description;

    // as an event can have multiple pois iterator trough pois and display infos
    foreach ($date->event->pois as $poi) {
        echo $poi->title;
        echo $poi->street_combined;
        echo $poi->city;
        echo $poi->zip;
    }
}

POIS

An example to collect pois

// create the client object with the access token
$client = new \Heartbeat\Client('MY_ACCESS_TOKEN');

// foreach trough pois, limited by pages.
foreach (\Heartbeat\Poi::findAll($client) as $poi) {
    echo $poi->title;
    echo $poi->id;
}

Get all events and openinghours for a given POI id 1337:

// create the client object with the access token
$client = new \Heartbeat\Client('MY_ACCESS_TOKEN');

$poi = \Heartbeat\Poi::find()->viewOne(1337);

if (!$poi) {
    throw new \Exception("Unable to find the given POI id");
}

foreach ($poi->eventDates as $date) {
    echo $date->start_timestamp;
}

Streams

Accessing stream data:

foreach (\Heartbeat\Stream::findItems('stream-alias', $client) as $item) {
    echo $item->id;
}