问题
I need to POST a HTML form to a 3rd party website (a Mass-SMS texting system).
In the past I've done this by forwarding to a page containing a form I've pre-populated and hidden (using display:none
), then I've ran a javascript function at the end of the page to automatically submit this form.
However I'm hoping theres someway I can do all this programmatically (as I don't care about the response, and the user doesn't need to see the page the form is being posted to).
How can I do this? Cheers
回答1:
You could use a WebClient.UploadValues method to send an HTTP POST request to a remote server from your code behind. Just fill up the name/value collection with the values coming from the hidden fields.
回答2:
If you're willing to get into PHP, you can very easily use cURL for this. Otherwise it's going to be quite difficult using just Javascript.
See here for a detailed tutorial.
来源:https://stackoverflow.com/questions/4757173/post-a-html-form-programmatically