我想传入当前用户cookiewp_remote_get 函数获取草稿后预览页面内容。
我已经检查了以下问题:
- What URL do you pass to wp_remote_get to load the body of the current post's preview?
- How can I call "preview post" from wp_remote_get with authentication? wp_remote_get 作用
我想我可以做我想做的事把饼干传给wp_remote_get 作用here in WordPress documentation 提到WordPress是如何存储cookie的,但我如何让他们注意到他们在cookie名称中使用了哈希值?
我想做的是给帖子ID,获取WordPress帖子查看页面的内容并进行分析。对于已经发布的帖子,一切都很好,但对于草稿帖子,我发现页面不存在。以下是简化的代码:
此代码是在帖子所有者编辑它时执行的,因此用户已经过身份验证,并且请求是本地帖子。我如何才能实现wp\\u remote\\u get返回我预览后的页面内容?正如WordPress在我的浏览器中转到预览链接时所做的那样。(...) $post_permalink = get_permalink($post_id); $response = wp_remote_get($post_permalink); $whole_post_page = $response[\'body\']; (...)
提前感谢。