dimanche 3 juillet 2016

sending POST request to other website from view

im writing a sort of middle man for a api , basically other websites send their users to me and i connect them to an api

right now this is the pattern

in my view :

def init(request , client_id):
  // do some queries ... 
  return render(request , 'form.html' , {'data': data})

in my form.html i have a actuall form :

<form method="post" action="http://www.api.com/" >
<input type="hidden" key="{{data.key}}" />
</form>
<script> $('form').submit(); </script>

i need to load the form.html first becouse i have to post required data to www.api.com ... i would like to get ride of the form and send POST request from my view ... is it possible ?

please note that i have to redirect user to api.com and POST some data with him , not just send a post and get result in the background like you do with CURL

Aucun commentaire:

Enregistrer un commentaire