help with python data count

62 views
Skip to first unread message

Paul G.

unread,
Aug 5, 2017, 4:23:54 AM8/5/17
to VitaDock Online API

Hi there
I need to get my Cardiodock data for medical statistical purposes and I am not satisfied with the data exported via the web interface.

I would like to ask if there is someone out there who has ever made a python code to get a data count with the vitadock api or can
at least give me a hint where I am wrong in my code? My Idea was to start with a simple data count and later modify it to receive the actual data.

I am quite new to python and programming and I tried to modify the existing python example as found on github.
But I always get a:
 <Response [405]>
response.

The corresponding part of my code is:

    def getDataCount(self, application_token,application_secret, access_token, access_secret):
       
self.application_token = application_token
       
self.application_secret = application_secret
       
self.access_token = access_token
       
self.access_secret = access_secret
       
        h
= hashlib.sha256
        nonce
= generate_nonce()

        data
= {}
        data
['oauth_consumer_key'] = self.application_token
        data
['date_since'] = "0"
        data
['oauth_signature_method'] = "HMAC-SHA256"
        data
['oauth_timestamp'] = str(generate_timestamp())
        data
['oauth_nonce'] = nonce
        data
['oauth_version'] = "1.0"
        data
['oauth_token'] = self.access_token
       
        base_string
= []
       
for k in sorted(data.keys()):
            base_string
.append(k + urllib.quote("=",'') +urllib.quote(data[k],''))
       
        base_string
= "GET&" + urllib.quote(self.count_url,'') + "&" + urllib.quote("&",'').join(base_string)
       
       
print "base_string: " + base_string
       
        new_key
= self.application_secret + "&" + self.access_secret
       
        sign
= hmac.new(new_key, base_string, h)
        sign
= b2a_base64(sign.digest()).strip().decode('utf-8')
       
        data2
= []
       
for k in sorted(data.keys()):
            data2
.append(k + "=\"" +data[k] + "\"")
               
        data2
.append('oauth_signature="' + urllib.quote(sign,'') + '"')
       
        data2
= "OAuth " + ",".join(data2)
       
        data3
= {}
        data3
['Authorization'] = data2
       
print "count_url: " + self.count_url
       
print "headers: " + str(data3)
       
        rs
= requests.post(self.count_url, headers=data3)
       
print rs
       
return rs

did I miss something, any Ideas anyone?
Reply all
Reply to author
Forward
0 new messages