fork download
  1. <?php
  2. class DES
  3. {
  4. var $key;
  5. var $iv;
  6. function __construct( $key, $iv=0 ) {
  7. $this->key = $key;
  8. if( $iv == 0 ) {
  9. $this->iv = $key;
  10. } else {
  11. $this->iv = $iv;
  12. }
  13. }
  14.  
  15. function encrypt($str) {
  16. return base64_encode( openssl_encrypt($str, 'DES-CBC', $this->key, OPENSSL_RAW_DATA, $this->iv ) );
  17. }
  18. function decrypt($str) {
  19. $str = openssl_decrypt(base64_decode($str), 'DES-CBC', $this->key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $this->iv);
  20. return rtrim($str, "\x1\x2\x3\x4\x5\x6\x7\x8");
  21. }
  22.  
  23. function pkcs5Pad($text, $blocksize) {
  24. $pad = $blocksize - (strlen ( $text ) % $blocksize);
  25. return $text . str_repeat ( chr ( $pad ), $pad );
  26. }
  27. }
  28.  
  29. $date = date('YmdHis', time());
  30. $username = "testuser";
  31.  
  32. // ---- Integration environment ----
  33.  
  34. // Your own secret key
  35. $secretkey = "68B0C4827C6243FFA83285AF49371977";
  36.  
  37. // API url
  38. $url = "http://s...content-available-to-author-only...r.com/api/api.aspx";
  39.  
  40. // MD5 Signature key
  41. $md5key = "GgaIMaiNNtg";
  42.  
  43. // Encryption key
  44. $key = "g9G16nTs";
  45.  
  46. // Change for your currency if necessary
  47. $currency = "THB";
  48.  
  49. $QS = "method=LoginRequest&Key=".$secretkey."&Time=".$date."&Username=".$username."&CurrencyType=".$currency;
  50. $s = md5($QS.$md5key.$date.$secretkey);
  51.  
  52. $crypt = new DES($key);
  53. $q = $crypt->encrypt($QS);
  54.  
  55. $data = array('q' => $q, 's' => $s);
  56.  
  57. $options = array(
  58. 'http' => array(
  59. 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
  60. 'method' => 'POST',
  61. 'content' => http_build_query($data)
  62. )
  63. );
  64. $context = stream_context_create($options);
  65. echo $result = file_get_contents($url, false, $context);
  66.  
  67. ?>
Success #stdin #stdout #stderr 0.03s 26824KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/U8RxxJ/prog.php on line 65
PHP Warning:  file_get_contents(http://s...content-available-to-author-only...r.com/api/api.aspx): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/U8RxxJ/prog.php on line 65