hi all, I need some syntax help. I need to talk to a remote server, post a request adn receive the answer. I thought I would use the Stipe.py as a basis because it almost suits my needs. I need an equivalent of this curl statement to receive a list of my invoices the 8e7659.... is the api of my account:
1. curl -i -H "Content-type: application/json" -X GET \ 2. -u 8e76598954566f453ceac1d4e8aed304: \https://test.nl/api/invoices and I also need to be able to post an equivilent of: 1. curl -i -H "Content-type: application/json" -X POST \ 2. -u 8e76598954566f453ceac1d4e8aed304: \ 3. -d '{"invoice":{"external_id":"101","currency":"usd", "amount_in_fiat":"2.00"}}' \ 4. https://test.nl/api/invoices This would trigger a response someting like this: 1. {"address"=>"mvztT9xTaqkEmcu2wjLTuLTARS33AJvK4S", 2. "currency"=>"usd", 3. "amount"=>"0.03853", 4. "amount_in_fiat"=>"2.0", 5. "exchange_rate"=>"51.90739", 6. "internal_id"=>"ff702c579c99947a5542398372b96d60", 7. "redirect_uri"=>"https://test.nl/invoice/mvztT9xTaqkEmcu2wjLTuLTARS33AJvK4S"} I need to beable to retreive the fields from this. so to get me started I created a pay.py and placed it in the models folder, it looks like this: import urllib import simplejson class Pay: """ Usage: key='<api key>' d = Pay(key).charge( amount_in_fiat=100, currency='usd', description='test charge') print d print Pay(key).check(d['id']) print Pay(key).refund(d['id']) """ URL_CHARGE = 'https://%s:@Test.nl/api/invoices' URL_CHECK = 'https://%s:@Test.nl/api/invoices/%s' def __init__(self, key): self.key = key def charge(self, amount_in_fiat, currency='usd', description='test charge', more=None): if more: d.update(mode) params = urllib.urlencode(d) u = urllib.urlopen(self.URL_CHARGE % self.key, params) return simplejson.loads(u.read()) else: d = {'amount_in_fiat': amount_in_fiat, 'currency': currency, 'description': description} def check(self, charge_id): u = urllib.urlopen(self.URL_CHECK % (self.key, charge_id)) return simplejson.loads(u.read()) if __name__ == '__main__': key = raw_input('user>') d = Kojn(key).charge(100) print 'charged', d['paid'] s = Kojn(key).check(d[u'id']) print 'paid', s['paid'], s['amount_in_fiat'], s['currency'] default.py: def index(): key='8e76598954566f453ceac1d4e8aed304' d = Pay(key).charge( amount_in_fiat=100, currency='usd', description='test charge') return dict(d=d) However this doesn't work gives me the error: <class 'simplejson.decoder.JSONDecodeError'>(No JSON object could be decoded: line 1 column 0 (char 0)) I'm not yet a programmer and don't see all the relations within web2py yet so please explain your answers. Thanks, Ivo -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

