I'm trying to use keen.io in PHP application. The below code works fine from a eclipse ide but shows connection reset from chrome/firefox.
Any help is much appreciated.
- I used phpunittest to assert that instances are working fine. The test went successful. The analysis event has been verified in a js client and it works fine.
- Now i tried creating a debug profile from eclipse ide and i ran it both the create event and analysis event were successful
- When i try from Chrome/firefox there is no response. Inspection in to the debugger shows Failed to load resource: net::ERR_CONNECTION_RESET in chrome
Environment PHP version is 5.5.12 WampServer Windows 8 Local Applicaion
Edit: I further debugged it through the xdebug add-on for chrome and eclipse to find that the code broke in the following method
/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php - Line Number 330 where it has the function "protected function validate()".
Once i commented this everything seems to go fine.
Here is the code
<?php
namespace KeenIO\Tests\Client;
require_once __DIR__ . '/vendor/autoload.php';
include('/Firebase/TokenException.php');
include('/Firebase/TokenGenerator.php');
use Firebase\Token\TokenException;
use Firebase\Token\TokenGenerator;
use KeenIO\Client\KeenIOClient;
use Guzzle\Tests\GuzzleTestCase;
class KeenIOClientTest extends GuzzleTestCase
{
public function testThisMightHaveADb()
{
$projectId = "544a8064072719342addb0d5";
$readKey = "b2ec296d6a26d7208af256ea28361bfa0bfd8d3ec2989a2650505596bd33251c96293c90a5dc5a0b476211c30f477436a5b6ef58aa59e4e5259ab8faed48f5c0f418d7754920642651ab97a53c213d38a649fb9278f114ddf64592eff78d53f269fffb334ebb093ba88fbdbc851e33fb";
$client = KeenIOClient::factory([
'projectId' => $projectId,
'writeKey' => $writeKey,
'readKey' => $readKey
]);
echo "done";
//Check that the Client is of the right type
$this->assertInstanceOf('\Guzzle\Service\Client', $client);
echo "1";
$this->assertInstanceOf('\KeenIO\Client\KeenIOClient', $client);
echo "2";
//Check that the pass config options match the client's config
$this->assertEquals($projectId, $client->getConfig('projectId'));
echo "3";
$this->assertEquals($writeKey, $client->getConfig('writeKey'));
$this->assertEquals($readKey, $client->getConfig('readKey'));
echo $client->getProjectId();
$average = $client->average("temprBugs", ["target_property" => "PF", "timeframe" => "previous_5_days"]);
print_r ($average);
}
}
$testObject = new KeenIOClientTest();
$testObject ->testThisMightHaveADb();
?>