PHP_api接口教程(7)
发布时间:2021-06-06
发布时间:2021-06-06
$sysParams["partner_id"] = $this->sdkVersion; if (null != $session) {
$sysParams["session"] = $session; }
//获取业务参数
$apiParams = $request->getApiParas();
//签名
$sysParams["sign"] = $this->generateSign(array_merge($apiParams, $sysParams));
//系统参数放入 GET 请求串
$requestUrl = $this->gatewayUrl . "?";
foreach ($sysParams as $sysParamKey => $sysParamValue) {
$requestUrl .= "$sysParamKey=" . urlencode($sysParamValue) . "&"; }
$requestUrl = substr($requestUrl, 0, -1); //发起 HTTP 请求 try {
$resp = $this->curl($requestUrl, $apiParams); }
catch (Exception $e) {
$this->logCommunicationError($sysParams["method"],$requestUrl,"HTTP_ERROR_" $e->getCode(),$e->getMessage());
$result->code = $e->getCode(); $result->msg = $e->getMessage(); return $result; }
//解析 TOP 返回结果 $respWellFormed = false; if ("json" == $this->format) {
$respObject = json_decode($resp); if (null !== $respObject)
.