diff --git a/controller/Controller.php b/controller/Controller.php index 8e5c839..6617f04 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -191,7 +191,9 @@ Class Controller { } //request url via curl - protected function request($url, $postFields = array(), $timeout = 10, $pc = false) { + protected function request( + $url, $postFields = array(), $timeout = 10, $pc = false, $options = array() + ) { $s = curl_init(); curl_setopt($s, CURLOPT_URL, $url); @@ -203,6 +205,10 @@ Class Controller { curl_setopt($s, CURLOPT_POSTFIELDS, $postFields); } + if (!empty($options)) { + curl_setopt( $ch, CURLOPT_HTTPHEADER, $options); + } + //iphone client $user_agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'; //mac os client diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index eedb5a7..dda9fc6 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -210,7 +210,10 @@ Class FrontApiController extends SiteController { $params['sign'] = $this->sign($params, $heroUnionConfig['token']); $api = $heroUnionConfig['server_url'] . '/api/newtask/'; - $res = $this->request($api, $params); + $timeout = 10; + $pc = false; + $headers = array("Content-Type: application/json"); + $res = $this->request($api, $params, $timeout, $pc, $headers); return !empty($res) && $res['status'] == 200 ? $res['result'] : false; }