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
- What is different about using admin-ajax.php in an endpoint and just submitting a form from the front end?
- cURL running slow in WordPress
- Trouble Sending Elementor Form Data via cURL in WordPress
- WP_Error Object in wp_remote_post & wp_remote_get
- How to serialize a Gutenberg block from block attributes in PHP?
- Syntax error, unexpected ‘class’ (T_CLASS) on line 1 after upgrade to php 5.6.4
- get product attributes for current product and store it in a variable
- function_exists call in function.php
- the_post_thumbnail() based on the Post ID
- Unrendered content Cornerstone through REST API
- MySQL query performed 4 times inside loop
- How can i display 3 post types in same page?
- Ajax call to my WordPress website from an external application [duplicate]
- Get a Page’s attachments in Gallery order
- Using a nonce in a Custom Login Form
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- Is this code malidcous
- How to trash multiple post/product programmatically
- Put CSS inside a PHP file and include it the right way
- Force SSL using FORCE_SSL_ADMIN
- Proper way to edit a post via phpMyAdmin without breaking the compare revisions tool
- Sending jsPDF documents to the server
- Unit Test in WordPress
- Sum custom field values of particular taxonomy
- Custom Text in WooCommerce Order Processing Email Based on Products
- Add_action not working in required file of functions.php
- WordPress: get recent posts, delete the current category
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Slick + PHP + ACF + JQuery slide reveal not working
- inserting a post from an extern php file but post content doesn’t show on wp site
- Shortcode to show the code
- db converts decimal number wrong
- How do I find PHP file that contains content of my page?
- How to keep empty fields from appearing in php?
- Include Parent Term in wp_list_categories
- is_user_logged_in() not working in AJAX validation call
- Does anyone know all parameters of get_comments()
- preg_replace regex problem
- malware undetectable by multiple scans
- How to create a field in customize and show that in header.php?
- WordPress child pages not working
- Custom map_meta_cap filter does not return [‘do_not_allow’]
- PHP Output also in Child theme, but different
- Check in which custom taxonomy belongs and change the style
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
- Query the links Database
- How to internationalize header image?
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Settings API form – submit with AJAX
- WordPress 5.6 Application Passwords
- Get title of page containing post grid within the posts
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- Define global custom post
- WordPress creating a compund query or using data from one post type to access another
- Store data from JavaScript object to custom table in user account
- Permalink doesn’t navigate to post (changes only url)
- Javascript Tab Gallery with Advanced Custom Fields
- Generate a radius search of custom post type locations
- custom field – changing an element or background of id div – different versions not working
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- truncating imported rss-feeds
- WordPress 404 when using AJAX to call php function
- WordPress Setting API – There is no field in options.php
- WP_Query count of different meta key values [duplicate]
- How I can shorten this title length?
- Snapshot Theme from WooThemes — empty ‘alt’ attribute
- Converting Menu Links to List Elements
- I am trying to replace a string with other from function.php
- PHP warning: Undefined array key 2 in feed.php
- How to continuously developing a WP site that is already deployed in production without damaging it during development
- Custom field fetch error on woocommerce pdf invoice
- posts_clauses drop ACF get_field function
- WordPress @include( ‘template-config.php’ );
- Is there a hook that I can use when a fatal error occurs?
- in_footer: gives syntax error
- Embed dynamic media query in a Gutenberg block