array_implode() public static method

Implode an array with the key and value pair giving a glue, a separator between pairs and the array to implode.
public static array_implode ( string $glue, string $separator, array $array ) : string
$glue string The glue between key and value
$separator string Separator between pairs
$array array The array to implode
return string The imploded array
 public function testArrayImplodeWithTwoValues()
 {
     $val = array('testKey' => 'testValue', 'testKey2' => 'testValue2');
     $expected = 'testKey=testValue&testKey2=testValue2';
     $actual = Pusher::array_implode('=', '&', $val);
     $this->assertEquals($actual, $expected, 'auth signature valid');
 }
Beispiel #2
-3
 /**
  * Build the required HMAC'd auth string
  *
  * @param string $auth_key
  * @param string $auth_secret
  * @param string $request_method
  * @param string $request_path
  * @param array $query_params
  * @param string $auth_version [optional]
  * @param string $auth_timestamp [optional]
  * @return string
  */
 public static function build_auth_query_string($auth_key, $auth_secret, $request_method, $request_path, $query_params = array(), $auth_version = '1.0', $auth_timestamp = null)
 {
     $params = array();
     $params['auth_key'] = $auth_key;
     $params['auth_timestamp'] = is_null($auth_timestamp) ? time() : $auth_timestamp;
     $params['auth_version'] = $auth_version;
     $params = array_merge($params, $query_params);
     ksort($params);
     $string_to_sign = "{$request_method}\n" . $request_path . "\n" . Pusher::array_implode('=', '&', $params);
     $auth_signature = hash_hmac('sha256', $string_to_sign, $auth_secret, false);
     $params['auth_signature'] = $auth_signature;
     ksort($params);
     $auth_query_string = Pusher::array_implode('=', '&', $params);
     return $auth_query_string;
 }