• My website will receive POST requests from another site on the internet, when a users data needs to be processed. Is there an example of WP registering to receive external POST requests from the internet and processing them using PHP?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Requests can be processed by any of the usual WP entry points. Any of the API endpoints could be used. A specific page with a custom template could be used. admin-ajax.php and admin-post.php are possibilities. You can also define your own custom API route/endpoint.

    Which is best to use depends on what sort of request is being made and what sort of response is expected. If the transmitted data is all in JSON format, an API endpoint is likely the best choice. If you’re able to specify an URL query string (or an “action” POST field) as part of the request that the 3rd party uses to access your site, then admin-post.php would be a good entry point when non-JSON data is involved.

    Thread Starter kspambot

    (@kspambot)

    I will be getting a small amount of data with the POST. I will check on admin-post.php. Thank you.

    K-

    Thread Starter kspambot

    (@kspambot)

    bcworkz, Thanks for your help. I am having some trouble with this. Can you explain how you register for receiving an external HTTP POST request and responding to it? I would be glad to pay for the help. Thanks.

    K-

    Moderator bcworkz

    (@bcworkz)

    While I appreciate your willingness to compensate for assistance, such offers are not allowed by our forum guidelines. Allowing such a practice can lead to unpleasant consequences so we need to disallow even the very best of well meaning intentions. Additionally, I advise ignoring any cold call offers of paid assistance that might arise from your considerate offer here. If you do need paid help, I recommend jobs.wordpress.net. You will not find me there, but you will find experts willing to help you.

    How you’d set this up varies by what service you’re involved with. It’d be best if you checked that service’s documentation and support for specifics. Typically they provide information about the format of their request and what they expect in return, if anything. You provide them with an URL for where their request should be sent, for example https://example.com/wp-admin/admin-post.php?action="foofoo"

    You’d write an action callback function hooked to “admin_post_foofoo” or “admin_post_nopriv_foofoo” that handles whatever needs to be done. Emphasis on “typically”. YMMV.

    Thread Starter kspambot

    (@kspambot)

    Thanks for your help

    • This reply was modified 2 years, 2 months ago by kspambot.
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Processing 3rd Party POST requests in WP’ is closed to new replies.