On server B:
$result = wp_remote_post('http://serverA.com/?api=json', array(
'method' => 'POST',
'redirection' => 1,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => array(),
'cookies' => array()
));
if ( is_wp_error( $result ) ) {
return 'bad connection!';
}
$json = $result['body'];
$posts = json_decode($json);
Now you have $posts as usual php array. var_dump($posts)
will look like:
array(2) {
[0]=>
object(stdClass)#7918 (4) {
["id"]=>
int(19)
["title"]=>
string(18) "Early bird tickets"
["content"]=>
string(12) "that is good"
["imageurl"]=>
string(65) "http://localhost/PRACTISE/wp/wp-content/uploads/2016/10/news2.jpg"
}
[1]=>
object(stdClass)#7919 (4) {
["id"]=>
int(95)
["title"]=>
string(18) "See you next year!"
["content"]=>
string(11) "Lorem ipsum"
["imageurl"]=>
string(73) "http://localhost/PRACTISE/wp/wp-content/uploads/2016/11/tak_for_i_aar.jpg"
}
}