Пример #1
0
 /**
  * When calling a static variable, a Singleton of PatrolSdk\Patrol will be created just once
  * and the call will be redirected to the one matching the Singleton.
  *
  * @param string $name Function name, case sensitive!!
  * @param array $arguments Function arguments
  */
 public static function __callStatic($name, $arguments)
 {
     if (!self::$instance) {
         self::$instance = Entry::init();
     }
     return call_user_func_array([self::$instance, $name], $arguments);
 }
 /**
  * Register the SDK service.
  *
  * @return void
  */
 private function registerSdk()
 {
     $this->app['ps.sdk'] = $this->app->share(function ($app) {
         $config = $app['config'];
         $sdk = Sdk::init();
         $sdk->setApiKey($config->get('patrol.key'));
         $sdk->setApiSecret($config->get('patrol.secret'));
         $base_url = $config->get('patrol.api_url');
         if ($base_url) {
             $sdk->setApiBaseUrl($base_url);
         }
         return $sdk;
     });
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['patrolserver.laravel-patrol'] = $this->app->share(function ($app) {
         $key = $app['config']->get('patrol-sdk::patrol_key');
         $secret = $app['config']->get('patrol-sdk::patrol_secret');
         $base_url = $app['config']->get('patrol-sdk::patrol_api_url');
         $patrol = CorePatrol::init();
         $patrol->setApiKey($key);
         $patrol->setApiSecret($secret);
         if ($base_url) {
             $patrol->setApiBaseUrl($base_url);
         }
         return $patrol;
     });
     $this->app->bind('PatrolSdk\\Patrol', 'patrolserver.laravel-patrol');
 }
Пример #4
0
<?php

// Include the PatrolServer PHP SDK
require_once "../init.php";
// Usage of the SDK objects
use PatrolSdk\Patrol;
/*
 * Create the first Patrol instance
 */
$patrol1 = Patrol::init();
$patrol1->setApiKey('key_1');
$patrol1->setApiSecret('secret_1');
/*
 * Create a second Patrol instance, with a different key and secret combination
 */
$patrol2 = Patrol::init();
$patrol2->setApiKey('another_key_2');
$patrol2->setApiSecret('another_secret_2');