当前位置: 首页 > 阿里云优惠 > 阿里云服务器优惠>> 怎么让WordPress检索一个远程页面信息 – WordPress 教程

怎么让WordPress检索一个远程页面信息 – WordPress 教程


怎么让WordPress检索一个远程页面信息 – WordPress 教程
wordpress

WordPress可以很容易地得到一个远程文件的内容以及文件信息。

使用 wp_remote_get() 函数或wp_remote_post()来获取所需的URL。下面的例子显示了如何检索一个URL,并显示其内容以及文件信息。

此代码可以放在模版文件的任何位置。

<?php    $response = wp_remote_get( 'http://foo.com/file.txt' );   if( is_wp_error( $response ) ) {      echo 'Something went wrong!';   } else {      echo 'Response:<pre>';      print_r( $response );      echo '</pre>';   };    ?>   

服务器购买/咨询热线:1563700917115617636856

本文链接:http://www.sqxnmj.com/alfwq/28425.html
tags:
腾讯云服务器特惠

  • 关注微信
是否收录:

猜你喜欢

微信公众号