在这篇文章中,我们将为您详细介绍使用WordpressRESTAPI获取帖子缩略图的内容,并且讨论关于wordpress抓取网页的相关问题。此外,我们还会涉及一些关于AmazonAPIGateway:
在这篇文章中,我们将为您详细介绍使用 Wordpress REST API 获取帖子缩略图的内容,并且讨论关于wordpress抓取网页的相关问题。此外,我们还会涉及一些关于Amazon API Gateway:有没有办法像在 AWS 控制台中测试 REST API 一样测试 HTTP API?、Apache Livy Java API:将 REST api 调用转换为 java api 调用、Apache 上的 Wordpress:REST API 调用给出了以下意外结果:(404)、apigee 网关、authn 和 authz:REST API 调用另一个 REST API的知识,以帮助您更全面地了解这个主题。
本文目录一览:- 使用 Wordpress REST API 获取帖子缩略图(wordpress抓取网页)
- Amazon API Gateway:有没有办法像在 AWS 控制台中测试 REST API 一样测试 HTTP API?
- Apache Livy Java API:将 REST api 调用转换为 java api 调用
- Apache 上的 Wordpress:REST API 调用给出了以下意外结果:(404)
- apigee 网关、authn 和 authz:REST API 调用另一个 REST API
使用 Wordpress REST API 获取帖子缩略图(wordpress抓取网页)
如何解决使用 Wordpress REST API 获取帖子缩略图
我使用此代码通过 wordpress REST API 获取帖子,此代码非常有效并且可以很好地获取帖子,但我不知道如何通过此代码获取帖子缩略图。我在 wp_remote_get 函数中将 ?_embed 添加到 URL 末尾,缩略图地址在输出中,但我不知道如何在 PHP 中获取和显示图像 URL。
<?PHP
function get_posts_via_rest() {
// Initialize variable.
$allposts = '''';
// Enter the name of your blog here followed by /wp-json/wp/v2/posts and add filters like this one that limits the result to 2 posts.
$response = wp_remote_get( ''https://video.amniat98.com/wp-json/wp/v2/posts?_embed'' );
// Exit if error.
if ( is_wp_error( $response ) ) {
return;
}
// Get the body.
$posts = json_decode( wp_remote_retrieve_body( $response ) );
// Exit if nothing is returned.
if ( empty( $posts ) ) {
return;
}
// If there are posts.
if ( ! empty( $posts ) ) {
// For each post.
foreach ( $posts as $post ) {
// Use print_r($post); to get the details of the post and all available fields
//print_r($post);
// Show a linked title and post date.
$allposts .= ''<a href="'' . esc_url( $post->link ) . ''" target=\\"_blank\\">'' . esc_html( $post->title->rendered ) . ''</a>'';
}
return $allposts;
}
}
// Register as a shortcode to be used on the site.
add_shortcode( ''rest_posts'',''get_posts_via_rest'' );
解决方法
您正在寻找 has_post_thumbnail
、the_post_thumbnail
和 the_post_thumbnail_url
。
示例
<?php
/**
* The Loop
* @link https://developer.wordpress.org/themes/basics/the-loop/
*/
if ( have_posts() ):
while ( have_posts() ): the_post();
/**
* has_post_thumbnail()
* @link https://developer.wordpress.org/reference/functions/has_post_thumbnail/
*/
if ( has_post_thumbnail() ):
the_post_thumbnail();
/**
* get_the_post_thumbnail_url()
* @link https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/
*/
the_post_thumbnail_url();
endif;
endwhile;
endif; ?>
了解详情
- https://developer.wordpress.org/themes/basics/the-loop/
- https://developer.wordpress.org/reference/functions/has_post_thumbnail/
- https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/
Amazon API Gateway:有没有办法像在 AWS 控制台中测试 REST API 一样测试 HTTP API?
如何解决Amazon API Gateway:有没有办法像在 AWS 控制台中测试 REST API 一样测试 HTTP API?
我正在使用 AWS Lambda 和 Amazon API Gateway 构建 HTTP API。
在AWS控制台中,我可以通过Method Execution来测试REST APIs,但是在HTTP APIs配置页面中找不到类似的方式。
我怎样才能完成我想要的?
有没有好的方法可以做到这一点,或者出于某种原因没有这样的方法?
谢谢!
解决方法
如果不将路由+方法部署到阶段,然后使用 HTTP 客户端调用阶段的端点 URL,目前无法测试路由+方法的集成。
当您创建新的 HTTP API 时,您将获得一个默认阶段 $default
,该阶段启用了自动部署,因此每当您对 API 进行更改时,这些更改将通过 API 可见端点可以立即使用 HTTP 客户端进行测试。
Apache Livy Java API:将 REST api 调用转换为 java api 调用
如何解决Apache Livy Java API:将 REST api 调用转换为 java api 调用
我正在尝试使用 LivyClient 向 k8s 上正在运行的 Livy 集群提交作业。我可以使用下面的 REST api 来做同样的事情 -
kubectl exec --namespace livy livy-0 -- curl -s -k -H ''Content-Type: application/json'' -X POST --data ''{
"name": “abc”,"className": "com.example.SparkMain","numExecutors": 2,
"file": "s3a:///bucket/main_app.jar“,“files”: “s3a:///bucket/Spark0.scala”,“s3a:///bucket/k8-cco-site.xml”,“s3a:///bucket/log4j_infa_spark_driver.properties”,“s3a:///bucket/log4j_infa_spark_executor.properties”,"conf": { "spark.kubernetes.namespace": "livy" } }'' "http://<external_ip>:<external_port>/batches"
我正在尝试使用 Livy Java API 做类似的事情。假设我为 livy 服务器公开了一个公共/外部 IP,有人可以指导我如何将此 cURL 命令转换为 livy java API 调用之一吗?
我尝试遵循此示例 https://livy.incubator.apache.org/docs/latest/programmatic-api.html 但由于我已经有了 Spark 逻辑 Spark0.scala,我不确定如何实现 Job 类和相应的方法。
提前致谢!
Apache 上的 Wordpress:REST API 调用给出了以下意外结果:(404)
如何解决Apache 上的 Wordpress:REST API 调用给出了以下意外结果:(404)?
激活 wp_debug 并得到这个:
> The REST API call gave the following unexpected result: (404)
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head>
> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The
> requested URL was not found on this server.</p> <hr>
> <address>Apache/2.4.38 (Debian) Server at DOMAIN.COM Port 80</address>
> </body></html> .
在 Apache 服务器上全新安装 wordpress。
无法进行任何更改或上传或更新
出现以下错误: “发布失败。您可能处于离线状态。”
已经尝试更改永久链接,并运行 wordpress 的权限脚本..
我可以使用 wp-cli 添加和修改,但不能使用 wp-admin 页面。我已经加倍检查了文件/目录权限和 sql 所有权。都是对的
对此有任何帮助吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
apigee 网关、authn 和 authz:REST API 调用另一个 REST API
如何解决apigee 网关、authn 和 authz:REST API 调用另一个 REST API?
我们正在使用 apigee API 网关并公开一个 REST 端点。我们了解 apigee 支持 various options for securing 端点。
我们的用例是此 REST 端点应调用软件供应商提供的另一个 REST API。软件供应商有自己的身份验证和授权机制。基本上他们有用户和角色的概念。
我的问题是这种情况下的最佳实践是什么?我们应该在网关级别 authn 和 authz 还是在供应商 REST API 级别或两者兼而有之?
无论如何,在供应商 REST API 级别都没有转义 authn 和 authz。
请推荐。谢谢。
解决方法
就您而言,这首先取决于您是只是在供应商 API 前展示代理,还是您自己的 API 提供独特的服务,而供应商的 API 只是您的中间件可能做出的多个“调用”之一提供其整体价值。另一种看待它的方法是问:您的 API 端点的客户是您的唯一客户,还是他们真的只是供应商底层 API 的客户?如果这是您自己的唯一 API“产品”,您可以选择使用自己的 API 客户端 AuthN/AuthZ 层,或者如果您的端点实际上只是一个轻量级的抽象,您可以选择将凭据直接传递给供应商 API。 Net-net,这取决于您的端到端用例。
今天的关于使用 Wordpress REST API 获取帖子缩略图和wordpress抓取网页的分享已经结束,谢谢您的关注,如果想了解更多关于Amazon API Gateway:有没有办法像在 AWS 控制台中测试 REST API 一样测试 HTTP API?、Apache Livy Java API:将 REST api 调用转换为 java api 调用、Apache 上的 Wordpress:REST API 调用给出了以下意外结果:(404)、apigee 网关、authn 和 authz:REST API 调用另一个 REST API的相关知识,请在本站进行查询。
本文标签: