You are here

public function Content::__construct in GatherContent 7.3

Account constructor.

Parameters

string $username: API username.

string $api_key: API key.

File

includes/Content.inc, line 32
Contains GatherContent\Accont class.

Class

Content
Class Account.

Namespace

GatherContent

Code

public function __construct($username = NULL, $api_key = NULL) {
  if (is_null($username)) {
    $username = variable_get('gathercontent_username', '');
  }
  if (is_null($api_key)) {
    $api_key = variable_get('gathercontent_api_key', '');
  }
  if (empty($username || $api_key)) {
    watchdog('gathercontent', "Trying to call API without credentials.", array(), WATCHDOG_ERROR);
  }
  $this->client = new Client(array(
    'base_url' => 'https://api.gathercontent.com',
    'defaults' => array(
      'auth' => array(
        $username,
        $api_key,
      ),
      'headers' => array(
        'Accept' => 'application/vnd.gathercontent.v0.5+json',
      ),
    ),
  ));
}