I need to fetch the contents of a remote file. Which is better for performance - wp_remote_get, file_get_contents, or cURL?

How exactly does wp_remote_get work? Can you suppress errors, ex. @wp_remote_get ?


  • If you get errors, then please add the details of the errors to your question. Half a question is no question at all.
    – Otto
    Mar 31, 2013 at 6:01

1 Answer 1


Always use wp_remote_get when in a WordPress context. It figures out the correct way, be it curl or something else, and uses that. Simple.

  • 1
    Is it possible to supress errors with an '@' like other functions? Also, is it possible that wp_remote_get is not allowed on a server, but file_get_contents is allowed? How could I go about writing a function that uses file_get_contents if wp_remote_get gives an error? Thanks!
    – Mike
    Mar 31, 2013 at 3:10
  • To elaborate the HTTP API uses $request_order = array( 'curl', 'streams', 'fsockopen' ); so curl first if that fails streams then fsockopen. Errors are up to you how you handle them.
    – Wyck
    Mar 31, 2013 at 5:24
  • Without more information on the error, it's impossible to answer your question in any more detail. Make your question more explicit and clear. Additionally, you don't want to use file_get_contents, because that won't work on a majority of webhosts. If you get an error, then tell us the error so that we can give you correct information instead of guessing randomly at your problem.
    – Otto
    Mar 31, 2013 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.