Here is what I'm trying to do (nothing complex):
use Digest::MD5 qw(md5 md5_hex md5_b开发者_如何学Pythonase64);
$apikey = '1234';
$secret = '123';
$timestamp = gmdate('U');
$sig = md5($apikey . $secret . $timestamp);
echo $sig
So, the error occurs on the $timestamp = gmdate line.
What am I doing wrong?
I think you are looking for the gmtime
function, not the gmdate
function. Although, now that I see that you are passing 'U'
into it, I am confused.
Ah, I see now, PHP uses gmdate('U')
the same way Perl 5 uses gmtime()
.
Whoops, my memory failed, you need to use Time::Local
or POSIX::mktime
to turn the result of localtime
or gmtime
into the epoch seconds.
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw/mktime/;
use Time::Local qw/timegm/;
print "the time is now ", timegm(localtime()), " or ", mktime(gmtime()), "\n";
精彩评论