Friday, September 30, 2011

Retrieve a remote page using WordPress

How to retrieve a remote page using WordPress


If you want to get the content,file info from a remote file for use it in wordpress instal then follow the step describe below.
Use the wp_remote_get() function (Or wp_remote_post() is you prefer using the POST method) to retrieve the desired url. The following example describe how to retrieve an url and display its content as well as the file info.

This code can be used anywhere on your template files.

$response = wp_remote_get( 'http://sandipdas.in/file.txt' );
if( is_wp_error( $response ) ) {
echo 'Something went wrong!';
} else {
echo 'Response:';
print_r( $response );

';
}

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off