How to send a HTTP Post request using PHP Curl and WordPress

I managed to solve this by adding the following into my functions.php add_shortcode(‘my_shortode’, ‘my_function’); function my_function () { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_PORT => “2222”, CURLOPT_URL => “http://11.111.11.111:2222/folder/query”, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => “”, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => “POST”, CURLOPT_POSTFIELDS => “<root>\r\n <something1>username</something1>\r\n <something2>123456789</something2>\r\n <something3>Hello</something3>\r\n</root>\r\n”, CURLOPT_HTTPHEADER => …

Read more

WordPress transient not working with WP Engine

So I don’t know why the return $cached_result; in the else, but if that’s intentional, then you should probably do: return json_decode( $cached_result, true ); Because you’re caching the response body (which is a JSON string) and you’re reading the non-cached result like so: $array = json_decode($result, true);. But if that return was a mistake, …

Read more

cURL error for cron

This error is most often related to the server configuration! Contact your hosting company and ask the hosting support to check the following points: The server is running a recent version of PHP and the cURL library. Increase PHP Memory Limit settings. Ask your web host if there is some limitation with wp-cron, or if …

Read more

Using PODS data with save_post

Yes, whenever a post is saved you should see all of the input items in $_POST … if you’re not using something like xdebug to debug with, you could do something like: echo “<pre>”; var_dump( $_POST ); echo “</pre>”; To test and see what is all included in $_POST … note this is just for …

Read more