1

I'm trying out the ActiveCollab API for my first time. I had to use StackOveflow to figure out how to get the API token since the docs don't tell me this.

Below is my code:

/* GET INTENT */
$url = 'https://my.activecollab.com/api/v1/external/login';
$fields = array(
    'email' => "email@email.com",
    'password' => "****"
);

$intent = curl_post_connector($url, $fields);
$intent = $intent->user->intent;

/* GET TOKEN */
$url = 'https://app.activecollab.com/my_app_id/api/v1/issue-token-intent';
$fields = array(
    'intent' => $intent,
    'client_name' => 'My App Name',
    'client_vendor' => 'My Company Name'
);

$token = curl_post_connector($url, $fields);
$token = $token->token;

Everything above works and get's the token properly. What I find really weird is that I have to use API v1 to get this, and the docs on ActiveCollab's site don't mention any URL for API v5. It seems like this is the approach everything is taking here on StackOverflow.

Now with the token, I try to get my list of projects:

/* GET PROJECT */

$url = 'https://app.activecollab.com/my_app_id/api/v1/users';
$headers = array (
   "X-Angie-AuthApiToken" => $token
);
$projects = curl_get_connector($url, $headers);

var_dump($projects);

But this does not work. There is no error returned - it instead returns an array of languages for some reason! I don't want to paste the massive json object here, so instead I'll link you to a photo of it: https://www.screencast.com/t/7p5JuFB4Gu


UPDATE:

When attempting to use the SDK, it works up until I try getting the token (which is just as far as I got without the SDK). I'm getting Server Error 500, and when looking at the logs, it says:

/home/working/public_html/ac/index.php(21): ActiveCollab\SDK\Authenticator\Cloud->issueToken(123456789)
#1 {main}
  thrown in /home/working/public_html/ac/SDK/Authenticator/Cloud.php on line 115

This is line 115 of Cloud.php:

throw new InvalidArgumentException("Account #{$account_id} not loaded");

I honestly don't think I did anything wrong... there must be something wrong with my account ID.

Just for kicks, I commented out that line, and the error disappears and the page loads fine - except now I have no token...

steeped
  • 2,613
  • 5
  • 27
  • 43
  • 1
    Hey @steeped, I'm Srdjan from Active Collab dev team. First of all, API version has nothing to do with the Active Collab version, so your URL should be like the following: `$url = 'https://app.activecollab.com/my_app_id/api/v1/users';` Second, above you just dumped the response body, could you check what response status you get? I think you might have problem with setting up the headers properly. Can you use plain old curl with `curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Angie-AuthApiToken: ' . $token]);`? – Srdjan Marjanovic Oct 16 '17 at 21:58
  • @SrdjanMarjanovic I'm getting HTTP 401. Apparently I'm not authorized? https://www.screencast.com/t/GFotP2Qx – steeped Oct 17 '17 at 21:42
  • @SrdjanMarjanovic Any ideas? – steeped Oct 18 '17 at 13:00
  • I would strongly advise to use our [PHP SDK library](https://github.com/activecollab/activecollab-feather-sdk). You can easily obtain authentication token and perform other API requests. Documentation on how to use library should be pretty straightforward, but if you get stuck, please let me know – Srdjan Marjanovic Oct 18 '17 at 15:18
  • @SrdjanMarjanovic I tried using your SDK, but the repo is missing the autoload.php file... – steeped Oct 18 '17 at 15:37
  • The `autoload.php` is a file that [Composer](https://getcomposer.org) will generate for you. If choose not to use composer, but to clone/download the repo, than you will need to `require` all of the needed classes, before instantiating them. – Srdjan Marjanovic Oct 18 '17 at 16:33
  • @SrdjanMarjanovic Got it working, thank you. – steeped Oct 18 '17 at 21:39

0 Answers0