AdzoneCreate(); } public function AdzoneCreateApi($name){ $c = new TopClient; $c->appkey = "23260528"; $c->secretKey = "842fc308fb5f95b1250581f664cdcde8"; $req = new TbkAdzoneCreateRequest; $req->setSiteId("11458219"); $req->setAdzoneName($name); $resp = $c->execute($req); $resp=(array)$resp; if(array_key_exists("data",$resp)){ $pmodel=(array)$resp['data']; if(array_key_exists("model",$pmodel)){ $adzoneArr=explode("_",$pmodel['model']); $data['name']=$name; $data['adzone_id']=$adzoneArr[count($adzoneArr)-1]; $data['create_at']=date("Y-m-d",time()); $data['update_at']=date("Y-m-d",time()); DB::table("adzone")->insert($data); return $adzoneArr[count($adzoneArr)-1]; }else{ return ""; } }else{ return ""; } } // public function AdzoneCreate(){ set_time_limit(0); ini_set('memory_limit','1024M'); $AdzoneListName="tbk:adzoneList"; $lastAdzone=DB::table("adzone")->orderBy("id","desc")->first(); if(count($lastAdzone)>0){ $adzoneName=$lastAdzone->name; preg_match("/\d+/",$adzoneName,$adzoneNameArr); $api_last=$adzoneNameArr[0]; $api_last=intval($api_last)+1; }else{ $api_last=1; } for($i=0;$i<500;$i++){ $api_all="api_".$api_last; $adzoneId=$this->AdzoneCreateApi($api_all); $redis=new Redis(); $redis->connect(config('constants.REDIS_IP'),config('constants.REDIS_PORT')); $redis->auth(config('constants.REDIS_PASSWORD')); $redis->rpush($AdzoneListName,$adzoneId); $api_last+=1; if($api_last%20==0){ sleep(5); } } } }