Following the documentation here http://apidocs.teamup.com/ I have installed Guzzle library via composer require 'guzzlehttp/guzzle:^6.0'
...I then generated an API key.
On the sample code they have provided I tried Querying the Teamup API:
<?php
$client = new GuzzleHttp\Client(['headers' => ['Teamup-Token' => 'API KEY ']]);
$res = $client->get('https://api.teamup.com/ks73ad7816e7a61b3a/subcalendars');
echo $res->getStatusCode();
// "200"
echo $res->getHeader('content-type');
// 'application/json'
echo $res->getBody();
// {"subcalendars":[ ... ]}
?>
But can not get any response when I run the same on a browser. However, when I run the curl version on the terminal
curl "https://api.teamup.com/ks73ad7816e7a61b3a/subcalendars"
-H "Teamup-Token: API KEY"
I am getting the expected response.
Second Testing your API key
I tried this:
<?php
$client = new GuzzleHttp\Client(['headers' => ['Teamup-Token' => 'API_KEY']]);
$res = $client->get('https://api.teamup.com/check-access');
if ($res->isSuccessful()) {
echo 'Your API key works!';
} else {
echo 'API key test failed: ' . $res->getBody();
}
?>
No response but the curl version:
curl "https://api.teamup.com/ks73ad7816e7a61b3a/subcalendars"
-H "Teamup-Token: API_KEY"
has a response in json format. Clearly I seem to be doing something wrong. What could it be? Anyone? Thank you.