欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

[PHP]WordPress HTTP API

程序员文章站 2023-10-23 09:48:38
the wordpress http api makes fetching from or posting to remote servers a breeze. it does...

the wordpress http api makes fetching from or posting to remote servers a breeze. it does this by allowing you to be transport agnostic when you fetch or post something. the http api will choose the fastest and most reliable method out of the five different transports available in php. it’ll take care of discovering what transports are allowed on that server at that time.

the two most important functions and the ones you will probably use 99% of the time are:

  • wp_remote_get().
  • wp_remote_post().

    $body = wp_remote_retrieve_body( wp_remote_get( 'https://mysite.com/' ) );