Copy the contents of a Json via PHP and send it to the server [duplicate]

1

It is possible via PHP to copy the Json content of a page (an API that is generating a% dynamic% co) as this link and save to a directory inside my site" json / .json "? Because I could create a cron job to always do this once a day.

If it is not possible, I will always have to access this api, copy the content, create a json and upload it to the folder I want?

    
asked by anonymous 15.07.2015 / 17:01

1 answer

1

In this way:

$string  = file_get_contents("/home/pasta/test.json");

$arquivo = fopen('arquivo.json','w+');

if($arquivo){
    if (!fwrite($arquivo, $sring)){
        echo('Não foi possível atualizar o arquivo');
    }
    echo 'Arquivo atualizado com sucesso<br>';
    fclose($arquivo);
}
    
15.07.2015 / 17:08