WordPress是极不赞成直接使用curl的,而是推荐使用封装好的wp_remote_get和wp_remote_post。
从名字就能看出,wp_remote_get负责发起GET请求;wp_remote_post负责发起POST请求。
用法举例:
$response = wp_remote_get( 'https://api.github.com/users/wordpress' );
$body = wp_remote_retrieve_body( $response );
$http_code = wp_remote_retrieve_response_code( $response );
$last_modified = wp_remote_retrieve_header( $response, 'last-modified' );
其实,有个更通用的函数:wp_remote_request。
默认‘GET’请求:wp_remote_get()。
默认‘POST’请求:wp_remote_post()。
默认‘HEAD’请求:wp_remote_head()。
-
WordPress函数:国际化 _x() 获取具有gettext上下文的翻译字符串。WordPress函数:国际化 _x() 获取具有gettext上下文的翻译字符串。
-
WordPress函数:国际化 _ex 展示带上下文的翻译字符串WordPress函数:国际化 _ex 展示带上下文的翻译字符串
-
WordPress函数:国际化 _nx 翻译字符串,_n + _xWordPress函数:国际化 _nx 翻译字符串,_n + _x
-
WordPress函数:国际化 _nx_noop 在 pot 中注册字符串WordPress函数:国际化 _nx_noop 在 pot 中注册字符串
-
WordPress 6.5移除区块样板菜单项的方法WordPress 6.5新增的区块样板菜单项,可将不同区块组合成一个新的区块模板,方便重复使用。
-
WordPress做多语言企业网站近期常用小伙伴问追格小编,有没有计划做双语WordPress企业官网主题。
暂无评论,抢个沙发...