示例#1
0
文件: Api.php 项目: sparkreel/sdk
 /**
  * Construct an API client.
  *
  * To setup your own Guzzle client instance set $baseUrl and $options to null,
  * or anything else as they will be ignored, and use the $client parameter. This
  * is specially meant to be helpful in testing.
  *
  * @param string                 $baseUrl
  * @param array                  $options
  * @param \Guzzle\Service\Client $client
  */
 public function __construct($baseUrl = "https://api.sparkreel.com/v1", $options = array(), \Guzzle\Service\Client &$client = null)
 {
     if ($client === null) {
         $options['base_url'] = $baseUrl;
         $this->client = SparkreelClient::factory($options);
     } else {
         $this->client = $client;
     }
 }
示例#2
0
<?php

/**
 * User: Tabaré Caorsi <*****@*****.**>
 * Date: 8/21/13
 * Time: 10:19 AM
 *
 * Boostrap the php unit environment
 */
require_once realpath(dirname(__FILE__) . "/../vendor/autoload.php");
$serviceBuilder = new Guzzle\Service\Builder\ServiceBuilder();
// regular api client
$serviceBuilder->set('test.sparkreel', \Sparkreel\Sdk\SparkreelClient::factory(array("base_url" => "https://api.sparkreel/v1", "api_key" => "YmM4ZmY5OTQ0OTFjMDdjM2M0OGExODNkZmI2OThiOTQwOWZiOTAwOA==", 'ssl.certificate_authority' => 'system', 'curl.options' => array(CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0))));
// OAuth2 client
$serviceBuilder->set('test.oauth', \Sparkreel\Sdk\OAuth2\Client::factory(array('scheme' => 'http', 'hostname' => 'www.dev.sparkreel.com', 'client_id' => 'demoreel', 'client_secret' => 'demo_secret', 'ssl.certificate_authority' => 'system', 'curl.options' => array(CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0))));
Guzzle\Tests\GuzzleTestCase::setServiceBuilder($serviceBuilder);
//Set response mocks directory
Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . '/mock');
define("TEST_VIDEOS_PATH", __DIR__ . '/videos');
define("TEST_IMAGES_PATH", __DIR__ . '/images');
示例#3
0
 /**
  * Test that we can construct a client
  */
 public function testFactory()
 {
     $client = SparkreelClient::factory(array('api_key' => 'foo'));
     $this->assertEquals("https://api.sparkreel.com/v1", $client->getBaseUrl(true));
 }
示例#4
0
文件: Api.php 项目: sparkreel/sdk
 public function getGroupTotals()
 {
     $command = $this->client->getCommand('GetGroupTotals', array());
     return $this->client->execute($command);
 }