Insightly API does not work

265 views Asked by At

I am trying to connect to my Insightly account via API given on this link: https://github.com/Insightly/insightly-php

When I test the given code:

<?php
    require('insightly.php');
    function run_tests($apikey){
      $insightly = new Insightly($apikey);
      $insightly->test();
    }
    run_tests($argv[1]);
?>

Nothing actually happens, meaning it gives out a blank page. Of course I have changed the variable $apikey with the key given. I have tried with base64 encoding, single quotes, double quotes, but nothing really works. I have also tried on localhost as well as on my server.

Then I tried the code given on Github:

require("insightly.php");

$i = new Insightly('your-api-key');

$contacts = $i->getContacts();

Again, changing the api key with the one given, once normal and once in base64 encoding. This just gives me a 500 error.

Does anybody have any idea how to even connect to Insightly via API in PHP?

1

There are 1 answers

5
Juun On

This code is made for executing in cli. If you use it like this is will run in a browser or anything else for that matter.

<?php
require('insightly.php');

function run_tests($apikey){
  $insightly = new Insightly($apikey);
  $insightly->test();
}

$apikey = "[PLACE API KEY HERE]";
run_tests($apikey);

otherwise try the following:

require("insightly.php");

$i = new Insightly('your-api-key');
$contacts = $i->getContacts();
var_dump($contacts);