"; $data1 = json_encode( $data ); //print_r($data1); $service_url = $api_url.'PostRegister/'. $api_key; /* $curl = curl_init($service_url); //curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $data1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data1)) ); $curl_response = curl_exec($curl); curl_close($curl); */ $args = array( 'headers' => array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data1) ), 'body' => $data1, ); $result = wp_remote_post( $service_url, $args ); if ( !is_wp_error( $result ) ) { $curl_response = $result['body']; $decoded = json_decode( $curl_response ); if ( isset( $decoded->response->status) && $decoded->response->status == 'ERROR' ) { echo 'it is dying
'; die( 'error occured: ' . $decoded->response->errormessage) ; } //echo 'response ok -- testing'; //var_export($decoded->response); //print_r($decoded); return( $decoded ); } return null; } // cleans up data on POST function test_input( $data ) { $data = trim( $data ); $data = stripslashes( $data ); $data = htmlspecialchars( $data ); return $data; } ?>