本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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');
}