【问题标题】:AngularJS Wordpress JSON API Plugin returning html instead of jsonAngularJS Wordpress JSON API插件返回html而不是json
【发布时间】:2015-10-10 12:38:03
【问题描述】:

我正在尝试从我的 wordpress 博客中获取最近的帖子,但它返回的是 html 而不是 json。我想使用 json 来更轻松地访问博客内容。我已经安装并激活了插件。以下是我获取帖子的方法:

  $http.get('blog/?json=get_recent_posts')
  .success(function(data, status, headers, config){
      $scope.post = data;
      console.log(data);
  })
  .error(function(data, status, headers, config){-
      console.log("unable to access!!!!!!!!!!!");
  });

返回 html 而不是 json 的原因是什么?有什么解决方法吗?使用 jsonp 提到的其他一些帖子,但这对我也不起作用。

【问题讨论】:

    标签: javascript angularjs wordpress http-get wordpress-json-api


    【解决方案1】:

    我可能做错了,但是当我像这样在http://www.example.com/ 提出安装 Wordpress 的请求时:

    http://www.example.com/index.php?rest_route=/my/rest/route/here

    我最终得到了正确的回复。

    我花了很长时间才弄清楚这一点,最终在返回给我的 HTML 中找到了一个格式类似的 URL。我希望以 http://www.example.com/wp_json/wp/v2/my/rest/route/here 的身份提出请求,但我只收到了 HTML 响应。

    【讨论】:

      猜你喜欢
      • 2017-03-28
      • 2019-03-31
      • 2020-08-12
      • 2016-12-24
      • 2022-01-04
      • 1970-01-01
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多