public function testEncode() { $signature = Sign::encode("", "KEY"); $this->assertEquals("405b4e6c5e0370034caa8d9261be1819", $signature); $signature = Sign::encode("", "a"); $this->assertEquals("025b69987847314c3445f5cdb5c23830", $signature); }
/** * @param $mode * @param $action * @return string */ private static function sign_request($mode, $action) { $url = $action; if (strpos($url, '?') !== false) { $url .= "&apiKey=" . \Itwapp::$apiKey; } else { $url .= "?apiKey=" . \Itwapp::$apiKey; } $milliseconds = round(microtime(true) * 1000); $url .= "×tamp=" . strval($milliseconds); $signature = Sign::encode($mode . ":" . $url, Itwapp::$secretKey); return $url . "&signature=" . $signature; }