Ejemplo n.º 1
0
 public function testEncode()
 {
     $signature = Sign::encode("", "KEY");
     $this->assertEquals("405b4e6c5e0370034caa8d9261be1819", $signature);
     $signature = Sign::encode("", "a");
     $this->assertEquals("025b69987847314c3445f5cdb5c23830", $signature);
 }
Ejemplo n.º 2
0
 /**
  * @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 .= "&timestamp=" . strval($milliseconds);
     $signature = Sign::encode($mode . ":" . $url, Itwapp::$secretKey);
     return $url . "&signature=" . $signature;
 }