作者 lyh

gx登录生成token

@@ -61,7 +61,7 @@ if (!function_exists('http_post')) { @@ -61,7 +61,7 @@ if (!function_exists('http_post')) {
61 * @param type $url 61 * @param type $url
62 * @param type $post_data 62 * @param type $post_data
63 */ 63 */
64 - function http_post($url, $post_data, $header = [],$is_json = true) 64 + function http_post($url, $post_data, $header = [],$is_json = true,$timeout = 60)
65 { 65 {
66 if (empty($header)) { 66 if (empty($header)) {
67 $header = array( 67 $header = array(
@@ -73,6 +73,7 @@ if (!function_exists('http_post')) { @@ -73,6 +73,7 @@ if (!function_exists('http_post')) {
73 curl_setopt($ch, CURLOPT_URL, $url); 73 curl_setopt($ch, CURLOPT_URL, $url);
74 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 74 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
75 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 75 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  76 + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
76 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 77 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
77 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 78 curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
78 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); 79 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
@@ -301,8 +301,11 @@ class CNoticeController extends BaseController @@ -301,8 +301,11 @@ class CNoticeController extends BaseController
301 'language'=> $language, 301 'language'=> $language,
302 'is_sitemap' => $is_sitemap 302 'is_sitemap' => $is_sitemap
303 ]; 303 ];
304 -// http_post($c_url, json_encode($c_param));  
305 - NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$c_url,'c_params'=>$c_param])); 304 + try {
  305 + http_post($c_url, json_encode($c_param));
  306 + }catch (\Exception $e){
  307 + NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$c_url,'c_params'=>$c_param]));
  308 + }
306 } 309 }
307 $this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!'); 310 $this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
308 } 311 }