In a project, I have to show wp posts in website via .net. So, I created a php file in project root folder as 'latestnews.php'. When called from browser, everything is working fine and data is shown. But in postman though the data is shown status is coming as 404 not found.
How to solve this issue? Any help/suggestions are welcome. Url: http://109.74.4.178/worldwaterweek/latestnews.php?numberposts=5
latestnews.php
<?php
define('WP_USE_THEMES', false);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
$num = $_GET["numberposts"] ?: '10';
$posts = get_posts(array(
'posts_per_page' => $num,
));
$array = array();
foreach($posts as $val) {
start_wp();
$array[] = array(
'id' => $val->ID,
'title' => $val->post_title,
'link' => get_permalink($val->ID),
'publish_date' => $val->post_date,
'content' => strip_tags($val->post_content),
'image' => get_the_post_thumbnail_url($val->ID, 'full')
);
}
echo json_encode($array);
?>