WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I dont want to use a REST API to publish to wordpress.

I want to create a form on a wordpress page which will send a POST to an external REST API. Users will put in their information, and perhaps upload a file. When the press "submit" I want this information to be sent to a REST API on a different server (not wordpress).

Are there any plugins that allow this? Has anyone done this? Of course, I might run into troubles with this: http://en.wikipedia.org/wiki/Same_origin_policy

It looks like I want to do the reverse of this: http://wordpress.org/extend/plugins/json-api/ Instead of making a REST API for wordpress, I want to make wordpress communicate send a POST to an external REST API when a user presses a button on a form.

share|improve this question

I don't know of a plugin that does it in a general way; for the most part, you'll need to build something custom for each specific API you intend to communicate with.

For your purposes, the key function will be wp_remote_post(), which is a wrapper for the POST method of WP's HTTP class. (Use this instead of making manual cURL requests, because WP_Http has all kinds of fallbacks for different modes of HTTP transport.) Here's a nice introduction: http://yoast.com/wp-best-practice/wordpress-http-api/ Same origin policies generally only apply to browsers. wp_remote_post() and its ilk are fired on the server.

Sending data is pretty easy - just put an array into the 'body' of your wp_remote_post() call. The tricky part is always authentication - does the API server expect a pre-registered key, or some sort of oAuth handoff, or what. If it's as simple as a shared key, you can just pass it as part of the 'body' payload.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.