【发布时间】:2015-12-10 16:22:55
【问题描述】:
我正在尝试使用 WP REST API v2 插件将我的 wordpress 博客中的一些帖子输入我的 PHP 网站。我的代码是:
<?php
$json = file_get_contents('http://noticias.uscs.edu.br/wp-json/wp/v2/posts?filter[posts_per_page]=6&filter[orderby]=date');
// Convert the JSON to an array of posts
$posts = json_decode($json);
foreach ($posts as $p) {
echo '<p><a href="'.$p->link.'">'.$p->title->rendered.'</a><p>';
// Output the featured image (if there is one)
echo $p->featured_image ? '<img src="' . $p->featured_image->guid . '">' : '';
}
?>
[{"code":"json_no_route","message":"Nenhuma rota foi encontrada que corresponde com a URL e o m\u00e9todo de requisi\u00e7\u00e3o"}]
几乎所有内容都是正确的,除了未显示的特色图片。可能是什么问题?
【问题讨论】: