php - Using cURL instead of file_get_contents -


my web host not support file_get_contents security reasons support use of curl. can tell me convert short code using curl? i've been trying days no luck appreciated!

<?php $json_string = file_get_contents("http://api.wunderground.com/api/b2b4a1ad0a889006/geolookup  /conditions/q/ia/cedar_rapids.json"); $parsed_json = json_decode($json_string); $location = $parsed_json->{'location'}->{'city'}; $temp_f = $parsed_json->{'current_observation'}->{'temp_f'};  echo "current temperature in ${location} is: ${temp_f}\n"; ?> 

i recommend use socket

<?php $fp = stream_socket_client("tcp://api.wunderground.com:80", $errno, $errstr, 30); if (!$fp) {     echo "$errstr ($errno)<br />\n"; } else {     fwrite($fp, "get /api/b2b4a1ad0a889006/geolookup/conditions/q/ia/cedar_rapids.json http/1.0\r\nhost: api.wunderground.com\r\naccept: */*\r\n\r\n");     while (!feof($fp)) {         echo json_decode(fgets($fp));     }     fclose($fp); } ?> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -