Thank you for the response, I removed the initial paste from the post. here is the pay.py: http://pastebin.com/B8FyD9Md
he is the default.py: http://pastebin.com/Sc1DQijh I also tried a different way to receive the data which also failed; index2(). anyway the error for index is the following: <class 'simplejson.decoder.JSONDecodeError'> No JSON object could be decoded: line 1 column 0 (char 0) Version web2py™ (1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), 'stable') Python Python 2.7.3: /usr/bin/python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/gluon/restricted.py", line 204, in restricted exec ccode in environment File "/home/crypto/web2py/applications/kojncomm/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/kojncomm/controllers/default.py>, line 110, in <module> File "/usr/lib/pymodules/python2.7/gluon/globals.py", line 172, in <lambda> self._caller = lambda f: f() File "/home/crypto/web2py/applications/kojncomm/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/kojncomm/controllers/default.py>, line 53, in index description='test charge') File "/home/crypto/web2py/applications/kojncomm/models/kojn.py" <http://127.0.0.1:8000/admin/default/edit/kojncomm/models/kojn.py>, line 46, in charge return simplejson.loads(u.read()) File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 413, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 402, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 420, in raw_decode raise JSONDecodeError("No JSON object could be decoded", s, idx) JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0) Error snapshot [image: help] <class 'simplejson.decoder.JSONDecodeError'>(No JSON object could be decoded: line 1 column 0 (char 0)) I don't know how to see what the response is is I get. On Sunday, September 1, 2013 5:42:25 AM UTC+2, viniciusban wrote: > > First things, first. > > 1) Paste your code in a pastebin service, like pastebin.com and tell > us the url. In python, indentation is important. > 2) Paste all your error, telling in which line the error occurred. > 3) If your message says "no JSON object could be decoded", probably > you didn't get a string with json formatting. See what is returning to > you. > > > On Sat, Aug 31, 2013 at 8:19 AM, Ivo <ivo.ni...@gmail.com <javascript:>> > wrote: > > 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: > > > > curl -i -H "Content-type: application/json" -X GET \ > > -u 8e76598954566f453ceac1d4e8aed304: \https://test.nl/api/invoices > > > > and I also need to be able to post an equivilent of: > > > > curl -i -H "Content-type: application/json" -X POST \ > > -u 8e76598954566f453ceac1d4e8aed304: \ > > -d '{"invoice":{"external_id":"101","currency":"usd", > > "amount_in_fiat":"2.00"}}' \ > > https://test.nl/api/invoices > > > > This would trigger a response someting like this: > > > > {"address"=>"mvztT9xTaqkEmcu2wjLTuLTARS33AJvK4S", > > "currency"=>"usd", > > "amount"=>"0.03853", > > "amount_in_fiat"=>"2.0", > > "exchange_rate"=>"51.90739", > > "internal_id"=>"ff702c579c99947a5542398372b96d60", > > > > "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 web2py+un...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/groups/opt_out. > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.