getChanelSuoKaData($cid); if(!$suokaRequest == 'error'){ return 'error'; } $url = $suokaRequest['suoka_url']; $cookie_path = $this->getcCookiePatch($cid); // /www/sites/reapi/index/extend/data/cookie/5//cookie.txt $cookie_path .= 'cookie.txt'; // $cookies = file_get_contents($cookie_path); // var_dump($cookies);die; if (is_readable($cookie_path)) { $cookies = file_get_contents($cookie_path); // 处理文件内容 } else { // 文件不存在或不可读 $KaiDianBaoCookie = new KaiDianBaoCookie($this->app); $request = [ 'login_info' => [ 'username' => $suokaRequest['username'], 'password' => $suokaRequest['password'] ], 'login_url' => $suokaRequest['login_url'], 'cid' => $cid ]; $cookie_path = $KaiDianBaoCookie->login($request); if($cookie_path == 'error'){ return $cookie_path; }else{ $cookies = file_get_contents($cookie_path); } } $card_kind = $this->get_card_kind($pid, $cash); $ch = curl_init(); // 创建cURL资源对象 $postData = [ 'cardNo' => $cardno, 'cardPwd' => $cardpwd, 'card_kind' => $card_kind, 'cardFace' => $cash, 'lockType' => '1' ]; $options['cookie_file'] = $cookie_path; $result = http_post( $url, $postData, $options); $result = json_decode($result,true); // if(isset($result['msg']) && $result['msg'] == '锁卡成功'){ return 'ok'; }elseif(isset($result['msg']) && $result['msg'] == '登录失败,参数错误'){ unlink($cookie_path); if($num == 0){ $this->suoka($cid, $cardno, $cardpwd, $pid, $cash,1); } return 'error'; }else{ Log::write('kami', 'kaidianbao', $result); return 'error'; } } public function get_card_kind($pid,$cash) { $info = $this->getProductInfo($pid); if ($info) { if (isset($info['gid_rule']) && $info['gid_rule']) { $rule = json_decode($info['gid_rule'], true); if (isset($rule[$cash]) && $rule[$cash]) { $gid = $rule[$cash]; return $gid; } } if (isset($info['gid']) && $info['gid']) { return $info['gid']; } } } }