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
- register_rest_route, Compare purchase codes and send a response
- Authorization and execution of the link
- WP_Error Object in wp_remote_post & wp_remote_get
- How to create a loop where loop changes every post?
- How to create a loop that will display one post and stop?
- How make wp_nav() with my css?
- One folder to be accessible by one user
- Issues trying to add a href statment with PHP into a PHP Echo Statement [closed]
- Woocommerce linking variations
- Help with if/else loop [closed]
- Child-theme suddenly stopped working [closed]
- Set variable in javascript and using in my shortcode
- Twig+WordPress how to use array arguments inside a function?
- How to implement a custom sliding banner? [closed]
- metabox displaying on incorrect page
- I would like to alert message while another user is editing or update data in wordpress admin panel, what should i do?
- Header location [closed]
- how to loop through blog posts in php
- Saving User Input to PHP Variable
- Tittle of post instead of tittle of page in php
- It’s not showing full content for posts pages in wordpress “[…]” while customing some changes in the style.css file [closed]
- How do I convert a custom field to a php date format? [closed]
- JSON Object Value Show Undefine
- Create an if statement based on page_id
- Require Credits Footer
- I’m not able to get access $wpdb in my php file in wordpress
- append special url end of my website urls
- How to crop featured image in different sizes?
- How to find out the URL of enabled theme(s)?
- Submit cf7 form to cfdb as pdf/BLOB [closed]
- An automatic way to crop images of different sizes
- Javascript code not working – $ is not a function error
- Blog listing not showing dates for every post and arrow missing off image
- Show post like this image in my newssite [closed]
- Undefined variable notice [closed]
- How do I remove spammy links in WP theme footer?
- Pagination not working properly
- Detecting IP Address of someone using ‘copy’ function [closed]
- Display biography post for today’s birthday person
- php grabbing every post made?
- Functions.php file in a custom child theme messed up without backup
- paginate_links() returns NULL instead of the pagination links, but pagination is actually happening
- What is proper way to use the php if statement? [closed]
- is it possible to create cart functionality without woocommerce? [closed]
- php snippets in html are being commented out
- Running a php code after User clicks a button? [closed]
- Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\admin\products.php on line 148 [closed]
- get user role. parameter id return type string [closed]
- Please help to know why single.php crashes after I add this code [closed]
- What does this if-statement do?: if($pages=’ ‘) {}
- Please help! Parse error: syntax error, unexpected ‘
- Can you not edit the HTML and PHP of your WordPress without paying?
- Really slow WordPress site [closed]
- Retrieve Array from within Array [closed]
- $_html is empty when var dumped
- How to improve wordpress site creation process to increase productivity.
- $post->ID calls for current page, but what is the code to call for any new page created and published in WordPress?
- Your PHP installation appears to be missing the MySQL … After deleting and restarting from cpanel
- How can I fix my pagination?
- How to create shortcode of this PHP code
- How to increase excerpt length in wordpress? [duplicate]
- Insert PHP into wordpress page [duplicate]
- Are WordPress & PHP objectively and based on evidence going to die because the future is made of frontend rendering instead of server side rendering? [closed]
- Advanced Custom Fields Show PHP in Text Areas
- Event plugin problem any one solve .? [duplicate]
- Not able to see the error [closed]
- how to Show BEFORE TEXT before in wordpress get_comment_meta [closed]
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- Force array to be a string [closed]
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- Adding jquery using php function
- New to WordPress & Freelancing [closed]
- How to hide .js files on wordpress website using php or wp plugins or any? [closed]
- Add a “Next Post” & “Previous Post” styled button manually to a post
- How do I link the side images?