protected function createClient(History $history) { $path = sprintf('%s/../../fixtures/store_event', __DIR__); $client = ClientFactory::factory('123', []); $httpClient = $client->getHttpClient(); $mock = new Mock([$path]); $httpClient->getEmitter()->attach($mock); $httpClient->getEmitter()->attach($history); return $client; }
public function testFactoryWithCustomUserAgent() { $client = ClientFactory::factory('123', ['defaults' => ['headers' => ['User-Agent' => 'test']]]); $default = ['User-Agent' => 'test']; $this->assertSame($default, $client->getHttpClient()->getDefaultOption('headers')); }
<?php /* * (c) Waarneembemiddeling.nl * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ echo '<pre>'; require 'vendor/autoload.php'; $client = \KISSmetrics\ClientFactory::factory('123456789', ['defaults' => ['headers' => ['User-Agent' => 'your-app-name/1.0.0 +https://yourapp.com']]]); $history = new GuzzleHttp\Subscriber\History(); $client->getHttpClient()->getEmitter()->attach($history); try { $client->setProperties(['_p' => 'Facebook #23', 'Test' => 'TEst']); } catch (Exception $e) { echo $e; } foreach ($history as $row) { //print (string) $row['request']; print (string) $row['response']; }