Plugin / Active Collab 5 SDK

Raja Dileep Kumar

Description

Description

Connecting to Active Collab Cloud Accounts

`php

<?php

require_once ‘/path/to/vendor/autoload.php’;

// Provide name of your company, name of the app that you are developing, your email address and password.
$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud(‘ACME Inc’, ‘My Awesome Application’, ‘[email protected]’, ‘hard to guess, easy to remember’);

// Show all Active Collab 5 and up account that this user has access to.
print_r($authenticator->getAccounts());

// Show user details (first name, last name and avatar URL).
print_r($authenticator->getUser());

// Issue a token for account #123456789.
$token = $authenticator->issueToken(123456789);

// Did we get it?
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
print $token->getUrl() . “\n”;
print $token->getToken() . “\n”;
} else {
print “Invalid response\n”;
die();
}
<h3>Connecting to Self-Hosted Active Collab Accounts</h3>php
require_once ‘/path/to/vendor/autoload.php’;

// Provide name of your company, name of the app that you are developing, your email address and password. Last parameter is URL where your Active Collab is installed.
$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted(‘ACME Inc’, ‘My Awesome Application’, ‘[email protected]’, ‘hard to guess, easy to remember’, ‘https://my.company.com/projects’);

// Issue a token.
$token = $authenticator->issueToken();

// Did we get what we asked for?
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
print $token->getUrl() . “\n”;
print $token->getToken() . “\n”;
} else {
print “Invalid response\n”;
die();
}
`

SSL problems?

If curl complains that SSL peer verification has failed, you can turn it off like this:

`php

// Cloud
$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud(‘ACME Inc’, ‘My Awesome Application’, ‘[email protected]’, ‘hard to guess, easy to remember’, false);
$authenticator->setSslVerifyPeer(false);

// Self-hosted
$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted(‘ACME Inc’, ‘My Awesome Application’, ‘[email protected]’, ‘hard to guess, easy to remember’, ‘https://my.company.com/projects’, false);
$authenticator->setSslVerifyPeer(false);

// Client
$client = new \ActiveCollab\SDK\Client($token);
$client->setSslVerifyPeer(false);
`

Note: Option to turn off SSL peer verification has been added in Active Collab SDK 3.1.

Constructing a client instance

Once we have our token, we can construct a client and make API calls:

`php

$client = new \ActiveCollab\SDK\Client($token);
`

Listing all tasks in project #65 is easy. Just call:

`php

$client->get(‘projects/65/tasks’);
`

To create a task, simply send a POST request:

`php

try {
$client->post(‘projects/65/tasks’, [
‘name’ => ‘This is a task name’,
‘assignee_id’ => 48
]);
} catch(AppException $e) {
print $e->getMessage() . ‘

‘;
// var_dump($e->getServerResponse()); (need more info?)
}
`

To update a task, PUT request will be needed:

`php

try {
$client->put(‘projects/65/tasks/123’, [
‘name’ => ‘Updated named’
]);
} catch(AppException $e) {
print $e->getMessage() . ‘

‘;
// var_dump($e->getServerResponse()); (need more info?)
}
`

post()`` and ``put()`` methods can take two arguments:
  1. command (required) – API command,
  2. variables – array of request variables (payload)

To remove a task, call:

`php

try {
$client->delete(‘projects/65/tasks/123’);
} catch(AppException $e) {
print $e->getMessage() . ‘

‘;
// var_dump($e->getServerResponse()); (need more info?)
}
`

delete()`` method only requires ``command`` argument to be provided.

For full list of available API command, please check Active Collab API documentation.

Ratings

5
1 reviews

Rating breakdown

Details Information

Version

0.1

First Released

22 May, 2018

Total Downloads

156

Wordpress Version

-

Tested up to:

-

Require PHP Version:

-

Tags

There is no tag found

Contributors

This plugin has been closed.

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.