Example #1
0
 public function testFactory()
 {
     $client = Client::factory(array('scheme' => 'http', 'hostname' => 'www.dev.sparkreel.com', 'client_id' => 'demoreel', 'client_secret' => 'demo_secret'));
     $this->assertEquals("http://www.dev.sparkreel.com/oauth", $client->getBaseUrl(true));
     $this->assertEquals('demoreel', $client->getConfig('client_id'));
     $this->assertEquals('demo_secret', $client->getConfig('client_secret'));
 }
Example #2
0
 /**
  * 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 array                  $options
  * @param \Guzzle\Service\Client $client
  */
 public function __construct($options, \Guzzle\Service\Client &$client = null)
 {
     if ($client === null) {
         $this->client = Client::factory($options);
     } else {
         $this->client = $client;
     }
 }
Example #3
0
 /**
  * Generates a change password url
  *
  * @return string
  */
 public function getChangePasswordUrl()
 {
     $url = sprintf("%s/change-password?client_id=%s&state=%s", $this->client->getBaseUrl(), $this->client->getConfig('client_id'), md5(uniqid()));
     return $url;
 }
Example #4
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');