当前位置: 首页>>代码示例>>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;未经允许,请勿转载。