Пример #1
0
 public function testCreatePushURI()
 {
     $client = new Client('', true);
     $pushUri = $client->getPushURI((new Message())->setDeviceIdentifier('foobar'));
     $this->assertContains('develop', $pushUri);
     $this->assertContains('foobar', $pushUri);
 }
Пример #2
0
 /**
  * Pushes an event to Connect.
  * @param string|array $collectionNameOrBatch The name of the collection you are pushing to or alternatively a batch of events.
  * Batches should be an associative array containing arrays of events keyed by collection name.
  * @param array $eventOrEvents Either a single event as an associative array, or an array of events as associative arrays
  * @return Response|array Either a response for single events or an Array of Responses for batch events
  */
 public static function push($collectionNameOrBatch, $eventOrEvents = null)
 {
     if (!isset(self::$client)) {
         throw new ConfigurationException('You must call initialize first with a Project Id and a Push Key');
     }
     return self::$client->push($collectionNameOrBatch, $eventOrEvents);
 }
Пример #3
0
 public function testClose()
 {
     $c = new Client();
     $c->connect();
     $this->assertInstanceOf("Bunny\\Protocol\\MethodChannelCloseOkFrame", $c->channel()->close());
     $c->disconnect();
 }
Пример #4
0
function lxserver_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv, $argc;
    if ($argv[1] === 'slave') {
        $login = new Client(null, null, 'slave');
        $gbl->is_slave = true;
        $gbl->is_master = false;
        $rmt = unserialize(lfile_get_contents("__path_slave_db"));
        $login->password = $rmt->password;
        $argv[1] = "Running as Slave";
    } else {
        if ($argv[1] === 'master') {
            $login = new Client(null, null, 'admin');
            $gbl->is_master = true;
            $gbl->is_slave = false;
            $login->get();
            $argv[1] = "Running as Master";
        } else {
            print "Wrong arguments\n";
            exit;
        }
    }
    $login->cttype = 'admin';
    // Set php script execution timer to unlimited
    set_time_limit(0);
    // Start internal socket for remote
    some_server();
}
 public function logInAs($username)
 {
     $crawler = $this->client->request('GET', '/login');
     $form = $crawler->filter('button[type=submit]')->form();
     $data = ['_username' => $username, '_password' => 'mypassword'];
     $this->client->submit($form, $data);
 }
 public function actionCompleteRegistrationAjax()
 {
     $client = new Client();
     $client->attributes = $_POST['Client'];
     if ($client->save()) {
         $drive = new Drive();
         $drive->attributes = $_POST['Drive'];
         $drive->client_id = $client->primaryKey;
         $drive->creation_date = date("Y-m-d H:i:s");
         if ($drive->save()) {
             $driv = Drive::model()->findByPk($drive->primaryKey);
             $message = new YiiMailMessage();
             $message->view = 'pruebamanejo';
             $message->setBody(array("client" => $client, "drive" => $driv), 'text/html');
             $message->setSubject('Solicitud Prueba de Manejo');
             foreach ($driv->concessioner->emails as $email) {
                 // if($email->type=="DRIVE"){
                 if ($email->type == "QUOTATION") {
                     $message->addTo($email->description);
                 }
             }
             //          		$message->addTo("*****@*****.**");
             //				$message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
             Yii::app()->mail->send($message);
             echo json_encode(true);
         } else {
             echo json_encode(false);
         }
     }
 }
Пример #7
0
 public function send($to, $txt)
 {
     $client = new Client($this->user, $this->token);
     $data = array("destinations" => $to, "text" => $txt);
     $response = $client->post('messages', $data);
     return $response->deliveryToken;
 }
Пример #8
0
/**
 * 创建client实例
 */
function &getSingleClient($smownerid)
{
    global $current_user;
    static $client = false;
    if ($client === false) {
        global $adb;
        $gwUrl = 'http://sdkhttp.eucp.b2m.cn/sdk/SDKService';
        $sql = "select * from ec_messageaccount where smownerid='" . $smownerid . "'";
        $result = $adb->query($sql);
        $serialNumber = trim($adb->query_result($result, 0, 'username'));
        $password = trim($adb->query_result($result, 0, 'password'));
        //$password='******';
        $sessionKey = $password;
        $connectTimeOut = 5;
        /**
         * 远程信息读取超时时间,单位为秒
         */
        $readTimeOut = 10;
        /**
                $proxyhost		可选,代理服务器地址,默认为 false ,则不使用代理服务器
                $proxyport		可选,代理服务器端口,默认为 false
                $proxyusername	可选,代理服务器用户名,默认为 false
                $proxypassword	可选,代理服务器密码,默认为 false
        */
        $proxyhost = false;
        $proxyport = false;
        $proxyusername = false;
        $proxypassword = false;
        $client = new Client($gwUrl, $serialNumber, $password, $sessionKey, $proxyhost, $proxyport, $proxyusername, $proxypassword, $connectTimeOut, $readTimeOut);
        $client->setOutgoingEncoding("UTF-8");
    }
    return $client;
}
Пример #9
0
 /**
  * The catalog view handler.
  * 
  * @param int $id The Product id.
  * @return string The HTML code.
  */
 public function view($id = null)
 {
     $Product = new Proud();
     $Product = $Product->findItem(array('Id = ' . $id));
     $Client = new Client();
     if (!$Product->Id) {
         return $this->halt();
     }
     $Category = $Product->getCategory();
     /*	$this->getView()->set('Product', $Product); */
     $this->getView()->set(array('Product' => $Product, 'Client' => $Client->findItem(array('Id = ' . $Product->CategoryId))));
     $this->getView()->setMethod('view');
     /*
     		if ( $Product->getCategory()->getLayout() instanceof Product_Layout_Custom )
     		{
     			$this->getView()->setMethod('custom');
     		}
     		elseif ( $Product->getCategory()->getLayout() instanceof Product_Layout_Common )
     		{
     			$this->getView()->setMethod('common');
     		}
     		$this->getView()->activeMenu = $Category;
     		$this->setContentPage($Category);
     		
     		$Page = $this->getContentPage();
     		$Page->SeoTitle = $Product->SeoTitle ? $Product->SeoTitle : $Product->Name;
     		$Page->SeoDescription = $Product->SeoDescription;
     		$Page->SeoKeywords = $Product->SeoKeywords;
     */
     return $this->getView()->render();
 }
Пример #10
0
 public function testClientCanBeCreated()
 {
     $a = new GiroAccount(123, 250);
     $b = new Client($a);
     $b->setAccount($a);
     $c = null;
 }
Пример #11
0
 /**
  * Perform a cURL request and decode the JSON response.
  * Can throw and exception if the request can't be successfully executed.
  *
  * @param Client $client   The client making the request, so we can extract
  *                         the API Key and Password
  * @param string $resource The API resource/path to request
  * @param string $method   The HTTP verb to use (GET|POST|PUT|DELETE)
  * @param array  $data     Collection of data to be sent with the request
  *
  * @return string Decoded JSON object
  */
 public static function request($client, $resource, $method, $data = array())
 {
     $curl = curl_init();
     $url = self::$endPoint . $resource;
     if (sizeof($data)) {
         if ($method == 'POST') {
             curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
         } elseif ($method == 'GET') {
             $url .= '?' . http_build_query($data);
         }
     }
     if ($method == 'POST' && sizeof($data)) {
         $body = json_encode($data);
     } else {
         $body = '';
     }
     $nonce = (int) (microtime(true) * 1000000.0);
     $message = $nonce . $url . $body;
     $signature = hash_hmac('sha256', $message, $client->getApiPass());
     $headers = array('Access-Key:' . $client->getApiKey(), 'Access-Nonce:' . $nonce, 'Content-Type:' . 'application/json', 'Access-Signature:' . $signature);
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_HEADER, 1);
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     $response = curl_exec($curl);
     if ($response === false) {
         throw new \Exception('No response from curl_exec in ' . __METHOD__);
     }
     $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
     $responseBody = substr($response, $headerSize);
     curl_close($curl);
     return json_decode($responseBody);
 }
Пример #12
0
 public function setUp()
 {
     // connect to mongo
     $client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
     // select database
     $this->database = $client->getDatabase('test');
 }
Пример #13
0
 /**
  * Get instance of connection
  * 
  * @param string $name connection identifier
  * @return \Sokil\Mongo\Client
  * @throws \Sokil\Mongo\Exception
  */
 public function get($name)
 {
     // get from cache
     if (isset($this->pool[$name])) {
         return $this->pool[$name];
     }
     // check if connection exists
     if (!isset($this->configuration[$name])) {
         throw new Exception('Connection with name ' . $name . ' not found');
     }
     // check if dsn exists
     if (!isset($this->configuration[$name]['dsn'])) {
         $this->configuration[$name]['dsn'] = null;
     }
     // check if connect options exists
     if (empty($this->configuration[$name]['connectOptions'])) {
         $this->configuration[$name]['connectOptions'] = null;
     }
     // init client
     $client = new Client($this->configuration[$name]['dsn'], $this->configuration[$name]['connectOptions']);
     if (isset($this->configuration[$name]['mapping'])) {
         $client->map($this->configuration[$name]['mapping']);
     }
     if (isset($this->configuration[$name]['defaultDatabase'])) {
         $client->useDatabase($this->configuration[$name]['defaultDatabase']);
     }
     $this->pool[$name] = $client;
     return $client;
 }
Пример #14
0
 public function add(Request $request)
 {
     // Ask if we are supplying our own data or requesting it from the server
     if ($request->has('remote') && ($request->remote = 'true')) {
         $client = new Client();
         $res = $client->request('GET', 'http://fsvaos.net/api/central/aircraft', ['query' => ['icao' => $request->icao]])->getBody();
         // Add the airport to the database
         $data = json_decode($res, true);
         $aircraft = new Aircraft();
         //return dd($data);
         $aircraft->name = $data[0]['name'];
         $aircraft->icao = $data[0]['icao'];
         $aircraft->maxgw = $data[0]['maxgw'];
         $aircraft->maxpax = $data[0]['maxpax'];
         $aircraft->range = $data[0]['range'];
         $aircraft->registration = $request->input('registration');
         $aircraft->enabled = true;
         $aircraft->hub = $request->input('hub');
         $aircraft->save();
     } else {
         // insert manual entry system.
         $aircraft = new Aircraft();
         //return dd($data);
         $aircraft->name = $request->input('name');
         $aircraft->icao = $request->input('icao');
         $aircraft->maxgw = $request->input('maxgw');
         $aircraft->maxpax = $request->input('maxpax');
         $aircraft->range = $request->input('range');
         $aircraft->registration = $request->input('registration');
         $aircraft->enabled = true;
         $aircraft->hub = $request->input('hub');
         $aircraft->save();
     }
 }
Пример #15
0
 /**
  * 
  * @param array $params
  * @return string MD5 hash
  */
 public function generateHash(array $params)
 {
     $hashParams = array();
     if (isset($params['transaction_id'])) {
         $hashParams[] = $params['transaction_id'];
     }
     if (isset($params['merchant_id'])) {
         $hashParams[] = $params['merchant_id'];
     }
     if (isset($params['order_id'])) {
         $hashParams[] = $params['order_id'];
     }
     if (isset($params['product_id'])) {
         $hashParams[] = $params['product_id'];
     }
     if (isset($params['user_id'])) {
         $hashParams[] = $params['user_id'];
     }
     if (isset($params['amount'])) {
         $hashParams[] = $params['amount'];
     }
     if (isset($params['descr'])) {
         $hashParams[] = $params['descr'];
     }
     if (isset($params['client_ip'])) {
         $hashParams[] = $params['client_ip'];
     }
     if (isset($params['time'])) {
         $hashParams[] = $params['time'];
     }
     return $this->client->generateHashResponse($hashParams);
 }
Пример #16
0
function lxserver_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv, $argc;
    // Set time limit to indefinite execution
    if ($argv[1] === 'slave') {
        $login = new Client(null, null, 'slave');
        //Initthisdef uses the db to load the drivers. NO longer callable in slave.
        //$login->initThisDef();
        $gbl->is_slave = true;
        $gbl->is_master = false;
        $rmt = unserialize(lfile_get_contents("__path_slave_db"));
        $login->password = $rmt->password;
        $argv[1] = "Running as Slave";
    } else {
        if ($argv[1] === 'master') {
            $login = new Client(null, null, 'admin');
            $gbl->is_master = true;
            $gbl->is_slave = false;
            $login->get();
            $argv[1] = "Running as Master";
        } else {
            print "Wrong arguments\n";
            exit;
        }
    }
    $login->cttype = 'admin';
    //set_error_handler("lx_error_handler");
    //set_exception_handler("lx_exception_handler");
    set_time_limit(0);
    some_server();
}
Пример #17
0
 public function testAudioInstanceCreatedForWord()
 {
     $c = new Client();
     $c->setApiKey('foobar');
     $request = $c->wordAudio('bar');
     $this->assertInstanceOf('Picnik\\Requests\\Word\\AudioRequest', $request);
 }
Пример #18
0
 public function getWeatherFor($city)
 {
     $client = new Client(['base_uri' => 'http://api.openweathermap.org/data/2.5/', 'timeout' => 2.0]);
     $response = $client->get('weather?q=' . $city);
     $contents = $response->getBody()->getContents();
     return json_decode($contents);
 }
Пример #19
0
 public function setUp()
 {
     // connect to mongo
     $client = new Client();
     // select database
     $this->database = $client->getDatabase('test');
 }
Пример #20
0
 public function setUp()
 {
     // connect to mongo
     $client = new Client();
     // select database
     $this->database = $client->map(array('test' => array('cars' => '\\Sokil\\Mongo\\DocumentRelationTest\\CarsCollection', 'engines' => '\\Sokil\\Mongo\\DocumentRelationTest\\EnginesCollection', 'wheels' => '\\Sokil\\Mongo\\DocumentRelationTest\\WheelsCollection', 'drivers' => '\\Sokil\\Mongo\\DocumentRelationTest\\DriversCollection', 'wrongRel' => '\\Sokil\\Mongo\\DocumentRelationTest\\WrongRelationCollection')))->getDatabase('test');
 }
Пример #21
0
 public function testConstruct_HostAndPortGiven_SetsCreateTransport()
 {
     $client = new Client('somehost', 7575);
     $transport = $client->getTransport();
     $this->assertInstanceOf('Everyman\\Neo4j\\Transport', $transport);
     $this->assertEquals('http://somehost:7575/db/data', $transport->getEndpoint());
 }
Пример #22
0
 /**
  * @param \Ilis\Bundle\PaymentBundle\Entity\Transaction\CreditCard $transaction
  */
 public function capture(CreditCardTransaction $transaction)
 {
     if (!is_numeric($transaction->getAmount()) || $transaction->getAmount() <= 0) {
         throw new Exception("Invalid amount");
     }
     // TODO: Check if the transaction has set the proper payment method
     $request = new WsRequest();
     $request->setOrder($transaction->getId());
     $amount = (double) number_format($transaction->getAmount(), 2, '.', '') * 100;
     $request->setAmount($amount);
     $request->setOrder($transaction->getIdentifier());
     $request->setMerchantCode($this->merchant->getCode());
     $request->setTerminal($this->merchant->getTerminal());
     $request->setCurrency($this->merchant->getCurrency());
     $request->setPan($transaction->creditCard);
     $request->setCvv2($transaction->cvv);
     $request->setExpiryDate(sprintf("%s%s", $transaction->expiryDateYear, $transaction->expiryDateMonth));
     $request->setTransactionType(WsTransaction::TYPE_AUTH);
     $this->merchant->signRequest($request);
     $response = $this->client->makeRequest($request);
     $operation = $response->getOperation();
     $authCode = $operation ? trim((string) $operation->Ds_AuthorisationCode) : null;
     if ($response->isValid() && !empty($authCode)) {
         $transaction->setStatus(Transaction::STATUS_SUCCESS);
         $transaction->setAuthCode((string) $response->getOperation()->Ds_AuthorisationCode);
     } else {
         $transaction->setStatus(Transaction::STATUS_ERROR);
         $transaction->setStatusCode((string) $response->getCode());
     }
     $transaction->setRawData($response->asXml());
 }
Пример #23
0
 protected static function createClient()
 {
     $config = static::getConfig();
     $client = new Client();
     $client->configure(['username' => $config['username'], 'password' => $config['password'], 'hostname' => $config['host'], 'port' => $config['port']]);
     return $client;
 }
Пример #24
0
 /**
  * @return null|Message
  */
 public function consume()
 {
     if ($this->ackExpected) {
         throw new \LogicException('Unable to consume message without ack to previous message');
     }
     $message = null;
     if ($this->timeout === null) {
         if ($this->reliably) {
             if (0 === $this->client->sadd($this->channel->getName(), array($this->getWorkingChannelName()))) {
                 throw new \RuntimeException("Not unique working channel name '{$this->getWorkingChannelName()}'");
             }
             $content = $this->client->rpoplpush($this->channel->getName(), $this->getWorkingChannelName());
         } else {
             $content = $this->client->rpop($this->channel->getName());
         }
     } else {
         if ($this->reliably) {
             $content = $this->client->brpoplpush($this->channel->getName(), $this->getWorkingChannelName(), $this->timeout);
         } else {
             $content = $this->client->brpop($this->channel->getName(), $this->timeout);
         }
     }
     if ($content !== null) {
         $message = new Message($content);
         if ($this->reliably) {
             $this->ackExpected = true;
         }
     }
     return $message;
 }
Пример #25
0
 public function loadData($pid, $name, $tmpDir)
 {
     // Upload to WebDav
     $webDav = new WebDav($this->gdClient->getUsername(), $this->gdClient->getPassword(), $this->gdClient->getUserUploadUrl());
     $dimensionName = Identifiers::getIdentifier($name);
     $tmpFolderNameDimension = "{$pid}-{$dimensionName}-" . uniqid();
     $tmpFolderDimension = $tmpDir . '/' . Identifiers::getIdentifier($name);
     mkdir($tmpFolderDimension);
     $timeDimensionManifest = self::getDataLoadManifest($dimensionName);
     file_put_contents("{$tmpFolderDimension}/upload_info.json", $timeDimensionManifest);
     copy(__DIR__ . '/time-dimension.csv', "{$tmpFolderDimension}/{$dimensionName}.csv");
     $webDav->createFolder($tmpFolderNameDimension);
     $webDav->upload("{$tmpFolderDimension}/upload_info.json", $tmpFolderNameDimension);
     $webDav->upload("{$tmpFolderDimension}/{$dimensionName}.csv", $tmpFolderNameDimension);
     // Run ETL task of time dimensions
     try {
         $this->gdClient->getDatasets()->loadData($pid, $tmpFolderNameDimension);
     } catch (Exception $e) {
         $debugFile = "{$tmpFolderDimension}/{$pid}-etl.log";
         $logSaved = $webDav->saveLogs($tmpFolderDimension, $debugFile);
         if ($logSaved) {
             $data = file_get_contents($debugFile);
             if ($data) {
                 $data = json_decode($data, true);
                 if ($data) {
                     $e = new Exception(json_decode(file_get_contents($debugFile), true), $e->getCode(), $e);
                 }
             }
         }
         throw $e;
     }
 }
Пример #26
0
 /**
  * 亿美短信发送接口
  * @param unknown $mobile 手机号
  * @param unknown $content 短信内容
  */
 private function _sendEmay($mobile, $content)
 {
     set_time_limit(0);
     define('SCRIPT_ROOT', BASE_DATA_PATH . '/api/emay/');
     require_once SCRIPT_ROOT . 'include/Client.php';
     /**
      * 网关地址
      */
     $gwUrl = C('sms.gwUrl');
     /**
      * 序列号,请通过亿美销售人员获取
      */
     $serialNumber = C('sms.serialNumber');
     /**
      * 密码,请通过亿美销售人员获取
      */
     $password = C('sms.password');
     /**
      * 登录后所持有的SESSION KEY,即可通过login方法时创建
      */
     $sessionKey = C('sms.sessionKey');
     /**
      * 连接超时时间,单位为秒
      */
     $connectTimeOut = 2;
     /**
      * 远程信息读取超时时间,单位为秒
      */
     $readTimeOut = 10;
     /**
     $proxyhost		可选,代理服务器地址,默认为 false ,则不使用代理服务器
     $proxyport		可选,代理服务器端口,默认为 false
     $proxyusername	可选,代理服务器用户名,默认为 false
     $proxypassword	可选,代理服务器密码,默认为 false
     */
     $proxyhost = false;
     $proxyport = false;
     $proxyusername = false;
     $proxypassword = false;
     $client = new Client($gwUrl, $serialNumber, $password, $sessionKey, $proxyhost, $proxyport, $proxyusername, $proxypassword, $connectTimeOut, $readTimeOut);
     /**
      * 发送向服务端的编码,如果本页面的编码为GBK,请使用GBK
      */
     $client->setOutgoingEncoding("UTF-8");
     $statusCode = $client->login();
     if ($statusCode != null && $statusCode == "0") {
     } else {
         //登录失败处理
         //    echo "登录失败,返回:".$statusCode;exit;
     }
     $statusCode = $client->sendSMS(array($mobile), $content);
     if ($statusCode != null && $statusCode == "0") {
         return true;
     } else {
         return false;
         print_R($statusCode);
         echo "处理状态码:" . $statusCode;
     }
 }
Пример #27
0
 public static function send(Client $client, $endPoint, $data = null, $method = 'GET', $contentType = 'application/json')
 {
     $url = $client->getApiUrl() . $endPoint;
     $method = strtoupper($method);
     if (null == $data) {
         $data = new stdClass();
     } else {
         if ($contentType == 'application/json' && $method != 'GET' && $method != 'DELETE') {
             $data = json_encode($data);
         }
     }
     if ($method == 'POST') {
         $curl = curl_init($url);
         curl_setopt($curl, CURLOPT_POST, true);
         curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
         if (is_array($data)) {
             if (isset($data['upload'])) {
                 $filename = $data['upload'];
                 $file = fopen($filename, 'r');
                 $size = filesize($filename);
                 $fileData = fread($file, $size);
                 curl_setopt($curl, CURLOPT_POSTFIELDS, $fileData);
                 curl_setopt($curl, CURLOPT_INFILE, $file);
                 curl_setopt($curl, CURLOPT_INFILESIZE, $size);
             }
         }
     } else {
         if ($method == 'PUT') {
             $curl = curl_init($url);
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
             curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
         } else {
             $url = $url . ($data != null ? (strpos($url, '?') === false ? '?' : '&') . http_build_query($data) : '');
             $curl = curl_init($url);
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method ? $method : 'GET');
         }
     }
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_USERPWD, $client->getAuthText());
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: ' . $contentType, 'Accept: application/json'));
     curl_setopt($curl, CURLINFO_HEADER_OUT, true);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
     curl_setopt($curl, CURLOPT_TIMEOUT, 30);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_VERBOSE, true);
     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($curl, CURLOPT_MAXREDIRS, 3);
     $response = curl_exec($curl);
     if ($response === false) {
         throw new Exception(sprintf('Curl error message: "%s" in %s', curl_error($curl), __METHOD__));
     }
     $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
     $responseBody = substr($response, $headerSize);
     $client->setDebug(curl_getinfo($curl, CURLINFO_HEADER_OUT), curl_getinfo($curl, CURLINFO_HTTP_CODE), substr($response, 0, $headerSize), $responseBody);
     curl_close($curl);
     return json_decode($responseBody);
 }
Пример #28
0
 /**
  * assert that putting a fetched resource fails
  *
  * @param string $url    url
  * @param Client $client client to use
  *
  * @return void
  */
 public function assertPutFails($url, $client)
 {
     $client->request('GET', $url);
     $client->put($url, $client->getResults());
     $response = $client->getResponse();
     $this->assertEquals(405, $response->getStatusCode());
     $this->assertEquals('GET, HEAD, OPTIONS', $response->headers->get('Allow'));
 }
Пример #29
0
 /**
  * Get Http Client
  *
  * @return Zend_Http_Client
  */
 public function getHttpClient()
 {
     if (!$this->_httpClient) {
         $this->_httpClient = new Zend_Http_Client();
         $this->_httpClient->setConfig(array('strictredirects' => true));
     }
     return $this->_httpClient;
 }
 /**
  * @param string $method
  * @param array $arguments
  * @return mixed
  * @throws \RuntimeException
  */
 public function __call($method, $arguments)
 {
     if ($this->reflectionClass->hasMethod($method)) {
         return $this->client->command(['Pure\\Command\\StorageCommand', $this->class, $this->name, $method, $arguments]);
     } else {
         throw new \RuntimeException("Class `{$this->class}` does not have method `{$method}`.");
     }
 }