Yes, it will do the same thing.
Taken from the official docs:
/** @var array|WP_Error $response */
$response = wp_remote_get( 'http://www.example.com/index.html' );
if ( is_array( $response ) && ! is_wp_error( $response ) ) {
$headers = $response['headers']; // array of http header lines
$body = $response['body']; // use the content
}
https://developer.wordpress.org/reference/functions/wp_remote_get/
Wether it will work for you though, is a different story. If both curl and javascript are returning null
, I don’t believe the problem is in the tool used to make the request, but rather what/how you’re requesting it.
If your code works everywhere, but does not work on your current host, then you need to speak with your host. Making the same request in a different way is unlikely to help.
Related Posts:
- calling admin-ajax.php from admin-ajax.php
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- Uploading media with the REST API
- cURL 28 error after switch from to brew php 7.2 on localhost
- Creating a post with the REST API, curl and oauth returning 401 error
- wp_remote_get returns an error for valid URL
- Creating login session via CURL
- wp_remote_get adding backslashes
- Where Does WordPress Make cURL Requests? How To Add cURL Option
- export a csv file from the database with a cronjob
- Programmatic Login from 3rd Party site
- get post content of particular post by url
- WordPress from url get external source title
- WordPress transient not working with WP Engine
- How to send a HTTP Post request using PHP Curl and WordPress
- SOAP Request/Parsing XML From wp_send_json_success
- REST API works in browser and via AJAX but fails via cURL
- cURL error 6 on news area, and also won’t auto update
- Post to WordPress from another Server via PHP
- Accessing an API with jQuery and AJAX
- Contactform7: display results from CURL
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- How to check if feed URL was requested?
- problem with ajax and the path to the php page
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Targeting single page with JS
- Remove General Tab and Plugin Tab in Settings in Woocommerce
- WooCommerce – Display variation custom field value [closed]
- WordPress Redirect: Default Password Reset URL [duplicate]
- Wrap First Character after in a tag
- How to Insert Shortcodes into Theme?
- How to filter posts by post format “standard” from wp-json api?
- Register JS for block on frontend only
- What does $wpdb->get_row return?
- Why is file_get_contents returning page source?
- Plugin CSS not enqueing
- What is an equivalent of single_cat_title for getting the slug of the category?
- WordPress Script stops suddenly
- Woocommerce api: create product with images – bad request
- PHP Fatal error: Uncaught Error: Call to undefined function wp_kses_normalize_entities() in new wordpress installation
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Are nonces in WP REST API optional by default?
- HTML tags not showing in excerpt
- Add .htm extention to a custom taxonomy
- Custom gallery in wp3.5
- Excecuting php function in shortcode
- Correct and safe way to include php content in my page
- Add content after the first post in WP Loop
- update_post_meta on multi-dimensional array options
- do_action(), iFrame Gets Displayed Despite Password Protection [closed]
- esc_url( ) won’t use https
- retain querystring values when savincustom options in admin
- Use post ID in functions.php file adminside
- How to show childs of certain custom post type in option list?
- How to edit HTML of my website on WordPress? [closed]
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- wpdb Cannot Update column in Database
- Change default gallery images – Currently they are displaying full size imagese
- How can I search all plugins for composer’s vendor/autoload.php?
- How do I prepare strings for insertions as values into a MySQL table?
- How to get post category list as select in front-end?
- how can I include some custom variable from functions.php?
- How to pick “full/thumbnail” images in the loop?
- How to remove the two duplicate values
- AJAX function running TWICE with WordPress admin-ajax.php
- OOP PHP class extends TwentyTwenty_Customize in Child Theme
- PHP using external anonymous function inside class
- How to make Subdomain work for product_tag?
- Woocommerce – Exclude variation attribute on specific variation
- Sort new column in Users wp-admin
- How to spell out a word in products/posts?
- How do I add a function to parent theme
- Custom PHP form needs refresh to load page correctly
- Child-Theme Category View with modified permalinks (%category% removed)
- Log out without confirmation request (nonce)
- Add Pre-Defined Value to Click Counter in WordPress
- Create a WordPress Contact Form to call a POST AWS API Gateway and send user data
- Show data obtained from a function and place it in a shortocode function
- Confuse between forms and tables
- Delete empty title_tags, find a h1 heading and echo it
- Get posts from year from URL
- HELP: cannot log into wordpress. PHP error
- WordPress is setting from header wrongly in wp_mail
- How to edit content in WordPress and the Polylang – plugin? – with demosite
- Add post title as a link parameter
- Help with find a bit of code to move from functions.php
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- Passing different content to template parts
- Filtered table in wordpress
- Hide cart when empty [closed]
- How to redirect unattached image attachments
- Overwriting a Shortcode
- WordPress changing single quotes to double quotes in title and content
- Easier URL to an image
- MySQL database migration to WordPress
- Is this WordPress code causing page weirdness? Can’t scroll to bottom
- Search result page – display values from the result’s metaboxes
- WordPress add parameters with friendly url structure
- Different behaviour between “include_once” and directly echoing out html code?
- how to display tables via ajax