Skip to content

Instantly share code, notes, and snippets.

@oterox
Created July 13, 2019 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oterox/dcf426298ed3eb56feb4b6e638f3806b to your computer and use it in GitHub Desktop.
Save oterox/dcf426298ed3eb56feb4b6e638f3806b to your computer and use it in GitHub Desktop.
wp_remote_get proveedores API
$response = wp_remote_get( 'http://192.168.1.9:8080/users' );
if ( is_array( $response ) ) {
$body = wp_remote_retrieve_body( $response );
$data = json_decode( $body );
if( ! empty( $data ) ) {
echo '<ul>';
foreach( $data->objects as $product ) {
echo '<li>';
echo '<a href="' . esc_url( $product->id ) . '">' . $product->email . '</a>';
echo '</li>';
}
echo '</ul>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment