Last active
December 13, 2015 20:38
-
-
Save urlbox/4971000 to your computer and use it in GitHub Desktop.
urlbox python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import hmac | |
from hashlib import sha1 | |
import urllib | |
def urlbox(key, secret, url, args): | |
qs = urllib.urlencode(dict(url=url, **args)) | |
signature = hmac.new(secret, qs, sha1) | |
token = signature.digest().encode('hex') | |
return "https://api.urlbox.io/v1/%s/%s/png?%s" % (key, token, qs) | |
argsDict = {'url' : "google.com", 'width': 1024, 'height': 768}; | |
print urlbox ("google.com", argsDict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code at line 9 breaks for me with an error that the argument URL is recieved multiple times by urlencode().
I switched to this to make it work: