Skip to content

Commit 1b1e7b8

Browse files
author
tanguofu
committed
fix bugs in python3
1 parent 8cadecf commit 1b1e7b8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

TencentYoutuyun/auth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import hmac, hashlib
66
import binascii
77
import base64
8-
import urlparse
98
from TencentYoutuyun import conf
109

1110
class Auth(object):
@@ -32,7 +31,7 @@ def app_sign(self, expired=0):
3231
now = int(time.time())
3332
rdm = random.randint(0, 999999999)
3433
plain_text = 'a=' + self._appid + '&k=' + self._secret_id + '&e=' + str(expired) + '&t=' + str(now) + '&r=' + str(rdm) + '&u=' + puserid + '&f='
35-
bin = hmac.new(self._secret_key, plain_text, hashlib.sha1)
34+
bin = hmac.new(self._secret_key.encode(), plain_text.encode(), hashlib.sha1)
3635
s = bin.hexdigest()
3736
s = binascii.unhexlify(s)
3837
s = s + plain_text.encode('ascii')

sample.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import time
44
import TencentYoutuyun
55

6+
# pip install requests
67
# please get these values from http://open.youtu.qq.com
78
appid = 'x'
89
secret_id = 'x'
@@ -12,8 +13,8 @@
1213
end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT
1314

1415
youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid, end_point)
15-
16-
#print youtu.FaceCompare('you_path_one.jpg','you_path_two.jpg')
16+
# for python3
17+
#print(youtu.FaceCompare('you_path_one.jpg','you_path_two.jpg'))
1718

1819
#print youtu.imageporn("./a.jpg")
1920
#print youtu.idcardocr("./a.jpg", 1)

0 commit comments

Comments
 (0)