WordPress.com API在本地工作,但不在应用程序引擎上



通过请求模块调用Wordpress API。在本地运行我的服务器时,调用会正确返回。使用poster可以正确返回url。

然而,当我将我的应用程序部署到谷歌应用程序引擎时,请求调用中的响应返回未定义的响应。

app.get('/api/test', (req, res) => {
console.log("testing"); 
// res.send({ express: 'Hello From testing' });
request('https://public-api.wordpress.com/rest/v1/sites/testblog.wordpress.com/posts', { json: true }, (err, response, body) => {
console.log(response.statusCode)
console.log(body); 
if (err) { return console.log(err); }
console.log(body);
res.send({ express: body.ID })
});
});

当应用程序引擎发出出站HTTPS请求(获取URL(时,它会检查所请求URL的证书。如果由于任何原因证书无效,应用程序引擎将拒绝该请求。根据文档,要禁用主机证书验证,请将verify_peer的值设置为false

您还应该了解URL获取的限制和配额。

相关内容

最新更新