My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
import hmac
import sha
import base64
def generate_timestamp(gmtime):
return time.strftime("%Y-%m-%dT%H:%M:%SZ", gmtime)

def generate_signature(service, operation, timestamp, secret_access_key):
my_sha_hmac = hmac.new(secret_access_key, service + operation + timestamp, sha)
my_b64_hmac_digest = base64.encodestring(my_sha_hmac.digest()).strip()
return my_b64_hmac_digest

import urllib2
import urllib
import time

ts = generate_timestamp(time.gmtime())
sig = generate_signature("CloudCache","POST",ts,'secret')
print "My signature = " + sig
url = "http://cloudcache.ws/4081"

print url
user_agent = "CloudCache Tester version 0.01"
headers = {'User-Agent' : user_agent , 'signature' : sig , 'timestamp' : ts , 'akey' : 'ccpy'}
data = {'val' : '3234233'}
data = urllib.urlencode(data)
try:
req = urllib2.Request(url, data, headers)
ret = urllib2.urlopen(req)

print str(ret.read())
except urllib2.HTTPError, e:
print e.code, str(e)

Change log

r4 by dr.marc.byrd on Feb 6, 2009   Diff
Completing change to ccpy akey

Go to: 
Project members, sign in to write a code review

Older revisions

r2 by dr.marc.byrd on Feb 6, 2009   Diff
First commit of python example files

All revisions of this file

File info

Size: 968 bytes, 33 lines
Powered by Google Project Hosting