app/Console/Commands/ClawContact.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
        dd('exit');
        $date_start = strtotime('2019-02-01');
        $date_end  = strtotime('2019-04-06');
        $asscess_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7ImlkIjoyOTI4NTQsInVzZXJfbmFtZSI6Ik5nXHUwMGY0IE1pbmggTmdcdTFlY2RjIiwidXNlcl9lbWFpbCI6ImdnMTA0NDM5NDQ5MjU1NTkyMjYyNTQ1Iiwicm9sIjoiYWRtaW4ifSwiaWF0IjoxNTU0MjA3MjEyLCJleHAiOjE1ODU2NTY4MTJ9._ZbanZq4EL9fcGbphqmEwIrUD8H48EYXqQGyH1USJQs";
        $fields = "id,user_id,rew_id,date,user_phone";
        $date = $date_start;
        for(;;){
            $this->text_data = '';
            $this->info(date('d-m-Y',$date));
            $date_query = date('d-m-Y',$date);
            if($date_end==$date){
                $page = 0;
                for(;;){
                    $page++;
                    $this->warn('Page:'.$page);
                    $url = "https:sosanhnha.com/api/v2/user-contacts?fields=$fields&date=$date_query&access_token=$asscess_token&type=filter_date&page=$page";
                    $content = file_get_contents($url);
                    $this->saveData($content,$date,$page);
                    break;
                }
                break;
            }else{
                $page = 0;
                for(;;){
                    $page++;
                    $this->warn('Page:'.$page);
                    $url = "https:sosanhnha.com/api/v2/user-contacts?fields=$fields&date=$date_query&access_token=$asscess_token&type=filter_date&page=$page";
                    $content = file_get_contents($url);
                    if($this->saveData($content,$date,$page)==false){
                        break;
                    }
                }
            }
            $date= $date + 86400;
        }
        $this->info('Finish!!');
    }
public function handle ( ) { dd ( 'exit' ) ; $ date_start = strtotime ( '2019-02-01' ) ; $ date_end = strtotime ( '2019-04-06' ) ; $ asscess_token = " eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7ImlkIjoyOTI4NTQsInVzZXJfbmFtZSI6Ik5nXHUwMGY0IE1pbmggTmdcdTFlY2RjIiwidXNlcl9lbWFpbCI6ImdnMTA0NDM5NDQ5MjU1NTkyMjYyNTQ1Iiwicm9sIjoiYWRtaW4ifSwiaWF0IjoxNTU0MjA3MjEyLCJleHAiOjE1ODU2NTY4MTJ9._ZbanZq4EL9fcGbphqmEwIrUD8H48EYXqQGyH1USJQs " ; $ fields = " id,user_id,rew_id,date,user_phone " ; $ date = $ date_start ; for ( ; ; ) { $ this -> text_data = '' ; $ this -> info ( date ( 'd-m-Y' , $ date ) ) ; $ date_query = date ( 'd-m-Y' , $ date ) ; if ( $ date_end == $ date ) { $ page = 0 ; for ( ; ; ) { $ page ++ ; $ this -> warn ( 'Page:' . $ page ) ; $ url = " https://sosanhnha.com/api/v2/user-contacts?fields= $ fields &date= $ date_query &access_token= $ asscess_token &type=filter_date&page= $ page " ; $ content = file_get_contents ( $ url ) ; $ this -> saveData ( $ content , $ date , $ page ) ; break ; } break ; } else { $ page = 0 ; for ( ; ; ) { $ page ++ ; $ this -> warn ( 'Page:' . $ page ) ; $ url = " https://sosanhnha.com/api/v2/user-contacts?fields= $ fields &date= $ date_query &access_token= $ asscess_token &type=filter_date&page= $ page " ; $ content = file_get_contents ( $ url ) ; if ( $ this -> saveData ( $ content , $ date , $ page ) == false ) { break ; } } } $ date = $ date + 86400 ; } $ this -> info ( 'Finish!!' ) ; }
Execute the console command.
Execute the console command .
//