<?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($yjXJD, $jPfeB = null, $mZanm = null) { $zeDuV = new ModStartOpenApi(); return $zeDuV->setApiBase($yjXJD)->setKey($jPfeB)->setSecret($mZanm); } public function setApiBase($yjXJD) { $this->apiBase = $yjXJD; return $this; } public function setKey($jPfeB) { $this->key = $jPfeB; return $this; } public function setSecret($mZanm) { $this->secret = $mZanm; return $this; } public function post($m2Dmo, $CnWtd) { goto wKXnQ; wKXnQ: $qHLCM = array(); goto gzgC_; Bot2J: if (Response::isError($f3Nqc)) { return Response::generateError($f3Nqc['msg']); } goto lVC7N; op7Z6: $qHLCM['sign'] = SignUtil::common($qHLCM, $this->secret); goto S0r0G; lVC7N: return $f3Nqc['data']; goto zBuDb; gzgC_: $qHLCM['key'] = $this->key; goto lOGHb; S0r0G: $f3Nqc = CurlUtil::postJSON($this->apiBase . $m2Dmo, json_encode(array_merge($qHLCM, $CnWtd)), array('header' => array('Content-Type' => 'application/json', 'Accept' => 'application/json'))); goto Bot2J; lOGHb: $qHLCM['timestamp'] = time(); goto op7Z6; zBuDb: } }