Browse Source

bug fix: call herounion api with json data

master
filesite 8 months ago
parent
commit
d2d16912ac
  1. 8
      controller/Controller.php
  2. 5
      themes/tajian/controller/FrontapiController.php

8
controller/Controller.php

@ -191,7 +191,9 @@ Class Controller {
} }
//request url via curl //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(); $s = curl_init();
curl_setopt($s, CURLOPT_URL, $url); curl_setopt($s, CURLOPT_URL, $url);
@ -203,6 +205,10 @@ Class Controller {
curl_setopt($s, CURLOPT_POSTFIELDS, $postFields); curl_setopt($s, CURLOPT_POSTFIELDS, $postFields);
} }
if (!empty($options)) {
curl_setopt( $ch, CURLOPT_HTTPHEADER, $options);
}
//iphone client //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'; $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 //mac os client

5
themes/tajian/controller/FrontapiController.php

@ -210,7 +210,10 @@ Class FrontApiController extends SiteController {
$params['sign'] = $this->sign($params, $heroUnionConfig['token']); $params['sign'] = $this->sign($params, $heroUnionConfig['token']);
$api = $heroUnionConfig['server_url'] . '/api/newtask/'; $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; return !empty($res) && $res['status'] == 200 ? $res['result'] : false;
} }

Loading…
Cancel
Save