Inconsistencies between wp_remote_post and cURL

As discovered above, headers need to be (seems so obvious now) key-value pairs, as opposed to an array of json-style key-values: $headers = array(); $headers[‘Content-Type’] = ‘application/json’; $headers[‘Api-Key’] = ‘{myapikey}’; $headers[‘Siteid’] = ‘99999’; And the body needs to be json so either: ‘body’ => “{\n \”Username\”: \”Siteowner\”,\n \”Password\”: \”apitest1234\”\n}” or ‘body’ => json_encode(array( ‘Username’ => … Read more

REST API custom endpoint to fetch pages and posts not working

First off, there’s a default endpoint for retrieving pages, but I presumed that you intentionally did not use it? Now the issues with your code: That $request->get_params() gets all the parameters and not a single one. So for single parameters, you should use $request->get_param(). $slug = $request->get_params(‘slug’); // incorrect $slug = $request->get_param( ‘slug’ ); // … Read more

How to receive JSON payload from a digital device

Your exact code would depend on how the HTTP notification is sent to your server and on the structure of the JSON, but the first building block is to listen for the incoming post request. There are lots of WP hooks that would be suitable. One is init, e.g.: add_action(‘init’, function() { $user=”the_correct_basic_auth_username”; $password = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)