using wp_remote_get instead of file_get_contents [duplicate]

Question

This question already has an answer here:

have run my theme through the Theme checker plugin and it seems upset about use of file_get_contents to get a json url. I’ve found posts saying i should use wp_remote_get. I’m currently decoding the url with the following:

$url = 'url' . $var;
$json =   file_get_contents($url,0,null,null);
$output = json_decode($json,true); 

The message I get from the Theme Checker is:

WARNING: file_get_contents was found in the file.php possible file operations.

Is it just saying this because there is a function I could possibly use by wordpress or any other reasons? Also how would I use wp_remote_get. I tried a few variations, mostly replacing file_get_contents with wp_remote_get with no luck. Doesn’t seem to decode the url at all.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/using-wp_remote_get-instead-of-file_get_contents-duplicate/">

using wp_remote_get instead of file_get_contents [duplicate]</a>
0
, David 7 months 0 Answers 50 views 0

Leave an answer