<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\App\OpenApi\Util; use ModStart\Core\Input\Response; use ModStart\Core\Util\CurlUtil; use ModStart\Core\Util\SignUtil; class ModStartOpenApi { private $apiBase; private $key; private $secret; public static function create($s2xpY, $ax5t3 = null, $zDVvb = null) { $qoHo2 = new ModStartOpenApi(); return $qoHo2->setApiBase($s2xpY)->setKey($ax5t3)->setSecret($zDVvb); } public function setApiBase($s2xpY) { $this->apiBase = $s2xpY; return $this; } public function setKey($ax5t3) { $this->key = $ax5t3; return $this; } public function setSecret($zDVvb) { $this->secret = $zDVvb; return $this; } public function post($xIfit, $EdQjV) { goto l5Xxy; mbdGd: return $JOw_A['data']; goto k_INX; l5Xxy: $Kp99R = array(); goto j2Zag; j2Zag: $Kp99R['key'] = $this->key; goto w0T4l; w0T4l: $Kp99R['timestamp'] = time(); goto pEbuO; zv2rD: $JOw_A = CurlUtil::postJSON($this->apiBase . $xIfit, json_encode(array_merge($Kp99R, $EdQjV)), array('header' => array('Content-Type' => 'application/json', 'Accept' => 'application/json'))); goto moorA; pEbuO: $Kp99R['sign'] = SignUtil::common($Kp99R, $this->secret); goto zv2rD; moorA: if (Response::isError($JOw_A)) { return Response::generateError($JOw_A['msg']); } goto mbdGd; k_INX: } }