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.

0
, David 4 years 2020-01-14T08:38:55-05:00 0 Answers 92 views 0

Leave an answer

Browse
Browse