Get file content from URL?

后端 未结 5 1977
逝去的感伤
逝去的感伤 2020-11-28 06:21

When I use following URL in browser then it prompt me to download a text file with JSOn content.

https://chart.googleapis.com/chart?cht=p3&chs=250x100&chd=t:

5条回答
  •  佛祖请我去吃肉
    2020-11-28 07:20

    Depending on your PHP configuration, this may be a easy as using:

    $jsonData = json_decode(file_get_contents('https://chart.googleapis.com/chart?cht=p3&chs=250x100&chd=t:60,40&chl=Hello|World&chof=json'));
    

    However, if allow_url_fopen isn't enabled on your system, you could read the data via CURL as follows:

    
    

    Incidentally, if you just want the raw JSON data, then simply remove the json_decode.

提交回复
热议问题