0) curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $result = curl_exec($ch); $errno = curl_errno($ch); curl_close($ch); return $result; } else { $context = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n" . 'Content-length: ' . strlen($params), 'content' => $params)); if ($timeout > 0) $context['http']['timeout'] = $timeout; $contextid = stream_context_create($context); $sock = @fopen($url, 'r', false, $contextid); if ($sock) { $result = ''; while (!feof($sock)) { $result .= fgets($sock, 8192); } fclose($sock); } else { return 'TimeOut'; } } return $result; }//end make_request() /** * 接口调用 * * @access public * @param mixed $paramsData 接口必要參數 * @param mixed $url 接口地址 * @return String */ public function sportsAgentParams($paramsData, $url) { $paramsSting = ''; $a = 0; foreach ($paramsData as $key => $value) { if ($a === 0) { $paramsSting .= $key . '=' . $value; } else { $paramsSting .= '&' . $key . '=' . $value; } $a++; } $params = base64_encode($paramsSting); $key = md5($params . S('sportsToken')); $loginUrl = $url . '?params=' . $params . '&Key=' . $key; return $loginUrl; }//end sportsAgentParams() }