I'm using an MVC framework. I have a URL like example.com/submit which displays a form that submits to itself, but I also want it to support programmatic submission (like an API). How can I find out if the url is being called by someone who typed the url and filled out the form and submi开发者_如何学Ctted it, or by someone who is doing it programatically with the api? Is there something in the headers or any other way to get a clue?
You can include a hidden field in your form that tells your application that it was sent through the HTML form. This field should only be used by your form and not by API calls. In that way you can easily differentiate between the calls.
精彩评论