扩展

HTTP Client

通过外部服务的 API 进行连接与交互。

Logo
Target Image

Click to watch tutorial video - 03:08

GraphQL 架构提供了全局字段,用于向 Web 服务器发送 HTTP 请求并获取其响应。

支持连接 REST API、GraphQL API 以及通用 API,并可检索和解码任意类型的数据(包括 HTML、XML 和 CSV)。

REST API: 此 query 连接到某个外部网站的 WP REST API,以获取其文章:

query {
  postData: _sendJSONObjectItemHTTPRequest(input: {
    url: "https://some-wp-rest-api.com/wp-json/wp/v2/posts/1/"
  })
}

...返回如下响应:

{
  "data": {
    "postData": {
      "id": 1,
      "date": "2019-08-02T07:53:57",
      "date_gmt": "2019-08-02T07:53:57",
      "guid": {
        "rendered": "https:\/\/newapi.getpop.org\/?p=1"
      },
      "modified": "2021-01-14T13:18:39",
      "modified_gmt": "2021-01-14T13:18:39",
      "slug": "hello-world",
      "status": "publish",
      "type": "post",
      "link": "https:\/\/newapi.getpop.org\/uncategorized\/hello-world\/",
      "title": {
        "rendered": "Hello world!"
      },
      "content": {
        "rendered": "\n<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n\n\n\n<p>I&#8217;m demonstrating a Youtube video:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Introduction to the Component-based API by Leonardo Losoviz | JSConf.Asia 2019\" width=\"750\" height=\"422\" src=\"https:\/\/www.youtube.com\/embed\/9pT-q0SSYow?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><figcaption>This is my presentation in JSConf Asia 2019<\/figcaption><\/figure>\n",
        "protected": false
      },
      "excerpt": {
        "rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing! I&#8217;m demonstrating a Youtube video:<\/p>\n",
        "protected": false
      },
      "author": 1,
      "featured_media": 0,
      "comment_status": "closed",
      "ping_status": "open",
      "sticky": false,
      "template": "",
      "format": "standard",
      "meta": [],
      "categories": [
        1
      ],
      "tags": [
        193,
        173
      ]
    }
  }
}

GraphQL API: 此 query 连接到 GitHub 的 GraphQL API,以获取仓库列表:

query FetchGitHubRepositories(
  $login: String!
  $githubAccessToken: String!
) {
  _sendGraphQLHTTPRequest(input:{
    endpoint: "https://api.github.com/graphql",
    query: """
    
query GetRepositoriesByOwner($login: String!) {
  repositoryOwner(login: $login) {
    repositories(first: 100) {
      nodes {
        id
        name
        description
      }
    }
  }
}
 
    """,
    variables: [
      {
        name: "login",
        value: $login
      }
    ],
    options: {
      auth: {
        password: $githubAccessToken
      }
    }
  })
}

通用 API: 此 query 连接到 WordPress 的 RSS 订阅源,并将 XML 解码为 JSON 对象:

query {
  _sendHTTPRequest(input: {
    url: "https://wordpress.com/blog/2024/07/16/wordpress-6-6/feed/rss/?withoutcomments=1"
  }) {
    body
    rssJSON: _strDecodeXMLAsJSON(
      xml: $__body
    )
  }
}

购买 All-Inclusive 套装

Personal
$79
/
“All-Inclusive” 套装
授权适用于 1 个域名
购买 ->
  • 1 个域名
  • 支持
  • 产品更新
Organization
$99
/
“All-Inclusive” 套装
授权适用于 3 个域名
购买 ->
  • 3 个域名
  • 支持
  • 产品更新
Professional
$199
/
“All-Inclusive” 套装
授权适用于 10 个域名
购买 ->
  • 10 个域名
  • 支持
  • 产品更新

授权有效期为 1 年(每年可续订)。价格以美元(USD)计。

需要更多域名?联系我们

30 天退款保证

购买任何扩展,均可申请退款保障

Features illustration
Money back guarantee

阅读我们的退款政策

Testimonial image

“这款插件真的是另一个层次!它能把你的网站提升到全新水平,变成一个强大的引擎。你越深入探索它的功能,就越会感到惊叹。如果你还在犹豫——赶紧入手吧,不然你以后会后悔的! 文档本身就说明了一切,扎实得不能再扎实。 Leo(开发者)是我遇到过的最敏锐、最全面的开发者之一。他的响应非常快,明显对自己的专业领域了如指掌。这款插件能做的事情之多,真的让我非常兴奋。可能性几乎无穷无尽,如果你重视 SEO,这款插件会让你的网站排名大幅提升。”

olmate - Web 开发者

订阅我们的新闻通讯

及时了解 Gato GraphQL 的所有更新。