Had the same issue. Changed $new_array = []; to $new_array = array(); in the line 142. It’s because [] is not working in older versions of php.
You may be able to find more information from the link below.
Language chooser in 4.0
Please refer to the following code.
you need to generate the nonce first to create a post.
$.ajax({
// get the nonce
dataType: 'jsonp',
url: '/api/get_nonce/?controller=posts&method=create_post',
type: 'GET',
success: function (data) {
// create the post
$.ajax({
url: '/api/create_post/',
type: 'POST',
dataType: 'jsonp',
data: {nonce: data.nonce, status:'xxxx',title:'xxxx', content:'xxxx'},
success: function (data) {
},
error: function (data) {
console.log('error');
}
});
},
error: function (data) {
console.log('error');
}
});
nonce is the key for creating a post.