v1.2.7.415

This commit is contained in:
RainLoop Team 2013-09-29 02:02:47 +04:00
parent 5c1e7bc676
commit 54e2645fcf
436 changed files with 407 additions and 347 deletions

View file

@ -0,0 +1,19 @@
<?php
namespace KeenIO\Http\Adaptor;
/**
* Class AdaptorInterface
*
* @package KeenIO\Http\Adaptor
*/
interface AdaptorInterface
{
/**
* post to the KeenIO API
*
* @param $url
* @param array $parameters
* @return mixed
*/
public function doPost($url, array $parameters);
}

View file

@ -0,0 +1,49 @@
<?php
namespace KeenIO\Http\Adaptor;
use Buzz\Browser;
use Buzz\Client\Curl;
/**
* Class Buzz
* @package KeenIO\Http\Adaptor
*/
final class Buzz implements AdaptorInterface
{
private $apiKey;
private $browser;
/**
* @param $apiKey
* @param null $client
*/
public function __construct($apiKey)
{
$this->apiKey = $apiKey;
$this->browser = new Browser(new Curl());
$this->browser->getClient()->setVerifyPeer(false);
}
/**
* post to the KeenIO API
*
* @param $url
* @param array $parameters
* @return mixed
*/
public function doPost($url, array $parameters)
{
$headers = array(
// 'Authorization' => $this->apiKey,
'Content-Type' => 'application/json'
);
$content = json_encode($parameters);
$response = $this->browser->post($url, $headers, $content);
return $response->getContent();
}
}