Title: JSON &#8211; Passing a query
Last modified: October 5, 2019

---

# JSON – Passing a query

 *  Resolved [logicred](https://wordpress.org/support/users/logicred/)
 * (@logicred)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/json-passing-a-query/)
 * I have been given a JSON endpoint, but need to pass it two POST parameters and
   a query. I know your plugin supports the resulting JSON import, but is there 
   any way I can pass it these params to generate the resulting JSON?

Viewing 1 replies (of 1 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/json-passing-a-query/#post-12010312)
 * Hi [@logicred](https://wordpress.org/support/users/logicred/)
 * You should be able to write some custom code that uses the http_api_curl() hook
   to do this. Here’s an untested example that you can modify as needed:
 *     ```
       // POST parameters when fetching feed
       add_action( 'http_api_curl', 'my_curl_set_opts', 10, 3 );
   
       function my_curl_set_opts( $handle, $r, $url ) {
           if ( $url == 'https://example.com/jsonfeed' ) {
               $data = array(
                   'client'            => 'CUSTOMER CODE',
                   'login'             => 'LOGIN',
                   'pass'              => 'PASSWORD'
               );
   
               $post_params = '';
               foreach ( $data as $pn => $pv ) {
                   $post_params .= ( $post_params == '' ? '' : '&' ) . $pn . '=' . urlencode( $pv );
               }
               curl_setopt( $handle, CURLOPT_POST, true );
               curl_setopt( $handle, CURLOPT_POSTFIELDS, $post_params );
               curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
               // Optional below (disable host/peer verification in case of SSL errors)
               // curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false );
               // curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, 0 );
           }
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘JSON – Passing a query’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/json-passing-a-query/#post-12010312)
 * Status: resolved