當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pusher::build_auth_query_string方法代碼示例

本文整理匯總了PHP中Pusher::build_auth_query_string方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pusher::build_auth_query_string方法的具體用法?PHP Pusher::build_auth_query_string怎麽用?PHP Pusher::build_auth_query_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pusher的用法示例。


在下文中一共展示了Pusher::build_auth_query_string方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create_curl

 /**
  * Utility function used to create the curl object with common settings
  */
 private function create_curl($s_url, $request_method = 'GET', $query_params = array())
 {
     # Create the signed signature...
     $signed_query = Pusher::build_auth_query_string($this->settings['auth_key'], $this->settings['secret'], $request_method, $s_url, $query_params);
     $full_url = $this->settings['scheme'] . '://' . $this->settings['host'] . ':' . $this->settings['port'] . $s_url . '?' . $signed_query;
     $this->log('curl_init( ' . $full_url . ' )');
     # Set cURL opts and execute request
     $ch = curl_init();
     if ($ch === false) {
         throw new PusherException('Could not initialise cURL!');
     }
     curl_setopt($ch, CURLOPT_URL, $full_url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->settings['timeout']);
     return $ch;
 }
開發者ID:AlexRed,項目名稱:Ozio-Chat,代碼行數:20,代碼來源:Pusher.php

示例2: get_channels

 public function get_channels()
 {
     $s_url = $this->settings['url'] . '/channels';
     # Create the signed signature...
     $signed_query = Pusher::build_auth_query_string($this->settings['auth_key'], $this->settings['secret'], 'GET', $s_url);
     $full_url = $this->settings['server'] . ':' . $this->settings['port'] . $s_url . '?' . $signed_query;
     # Set cURL opts and execute request
     $ch = curl_init();
     if ($ch === false) {
         die('Could not initialise cURL!');
     }
     curl_setopt($ch, CURLOPT_URL, $full_url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->settings['timeout']);
     $response = curl_exec($ch);
     $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($http_status == 200) {
         $response = json_decode($response);
         $response = $response->channels;
     } else {
         $response = false;
     }
     curl_close($ch);
     return $response;
 }
開發者ID:reydajp,項目名稱:Pusher,代碼行數:26,代碼來源:Pusher.php

示例3: create_curl

 /**
  * Utility function used to create the curl object with common settings
  */
 private function create_curl($s_url, $request_method = 'GET', $query_params = array())
 {
     # Create the signed signature...
     $signed_query = Pusher::build_auth_query_string($this->settings['auth_key'], $this->settings['secret'], $request_method, $s_url, $query_params);
     $full_url = $this->settings['scheme'] . '://' . $this->settings['host'] . ':' . $this->settings['port'] . $s_url . '?' . $signed_query;
     $this->log('curl_init( ' . $full_url . ' )');
     // Create or reuse existing curl handle
     static $ch;
     if (null === $ch) {
         $ch = curl_init();
     }
     if ($ch === false) {
         throw new PusherException('Could not initialise cURL!');
     }
     // curl handle is not reusable unless reset
     if (function_exists('curl_reset')) {
         curl_reset($ch);
     }
     # Set cURL opts and execute request
     curl_setopt($ch, CURLOPT_URL, $full_url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Expect:"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->settings['timeout']);
     return $ch;
 }
開發者ID:elNapoli,項目名稱:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代碼行數:28,代碼來源:Pusher.php

示例4: testGenerateSignature

 public function testGenerateSignature()
 {
     $time = time();
     $auth_version = '1.0';
     $method = 'POST';
     $auth_key = 'thisisaauthkey';
     $auth_secret = 'thisisasecret';
     $request_path = '/channels/test_channel/events';
     $query_params = array('name' => 'an_event');
     $auth_query_string = Pusher::build_auth_query_string($auth_key, $auth_secret, $method, $request_path, $query_params, $auth_version, $time);
     $expected_to_sign = "POST\n{$request_path}\nauth_key={$auth_key}&auth_timestamp={$time}&auth_version={$auth_version}&name=an_event";
     $expected_auth_signature = hash_hmac('sha256', $expected_to_sign, $auth_secret, false);
     $expected_query_string = "auth_key={$auth_key}&auth_signature={$expected_auth_signature}&auth_timestamp={$time}&auth_version={$auth_version}&name=an_event";
     $this->assertEquals($auth_query_string, $expected_query_string, 'auth signature valid');
 }
開發者ID:GregBrimble,項目名稱:notablenews,代碼行數:15,代碼來源:authQueryStringTest.php


注:本文中的Pusher::build_auth_query_string方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。