获取taoken保存为txt

2020-08-14  本文已影响0人  小进我是爸爸


function huodetoken(){
    $url='';
    $myfile = fopen("testfile.txt", "r");
    if($myfile){
        $data=fread($myfile,filesize("testfile.txt"));
        $data = json_decode($data,true);
        if(time()-$data['time']>7200 || $data['access_token']){

            $data=httpsends_get($url);
            $data = json_decode($data,true);
            $myfile = fopen("testfile.txt", "w");
            $data['time']=time();
            $data = json_encode($data,true);
            fwrite($myfile, $data);
        }
    }else{

        $data=httpsends_get($url);
        $data = json_decode($data,true);
        $myfile = fopen("testfile.txt", "w");
        $data['time']=time();
        $data = json_encode($data,true);
        fwrite($myfile, $data);
    }
上一篇下一篇

猜你喜欢

热点阅读