Beispiel #1
0
/**
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
function sendHttpRequest($params, $url)
{
    $opts = getRequestParamString($params);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type:application/x-www-form-urlencoded;charset=UTF-8'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $opts);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $html = curl_exec($ch);
    curl_close($ch);
    return $html;
}
Beispiel #2
0
/**
 * 后台交易 HttpClient通信
 * @param unknown_type $params
 * @param unknown_type $url
 * @return mixed
 */
function sendHttpRequest($params, $url)
{
    $opts = getRequestParamString($params);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    //不验证证书
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    //不验证HOST
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type:application/x-www-form-urlencoded;charset=UTF-8'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $opts);
    /**
     * 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
     */
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    // 运行cURL,请求网页
    $html = curl_exec($ch);
    // close cURL resource, and free up system resources
    curl_close($ch);
    return $html;
}
<?php 
header('Content-type:text/html;charset=utf-8');
include_once $_SERVER['DOCUMENT_ROOT'] . '/upacp_sdk_php/utf8/func/common.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/upacp_sdk_php/utf8/func/SDKConfig.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/upacp_sdk_php/utf8/func/secureUtil.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/upacp_sdk_php/utf8/func/httpClient.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/upacp_sdk_php/utf8/func/log.class.php';
/**
 *	预授权完成
 */
/**
 *	以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考
 */
// 初始化日志
$log = new PhpLog(SDK_LOG_FILE_PATH, "PRC", SDK_LOG_LEVEL);
$log->LogInfo("===========处理后台请求开始============");
$params = array('version' => '5.0.0', 'encoding' => 'utf-8', 'certId' => getSignCertId(), 'signMethod' => '01', 'txnType' => '03', 'txnSubType' => '00', 'bizType' => '000201', 'accessType' => '0', 'channelType' => '07', 'orderId' => date('YmdHis'), 'merId' => '888888888888888', 'origQryId' => '201502281110005523968', 'txnTime' => date('YmdHis'), 'txnAmt' => '100', 'backUrl' => SDK_BACK_NOTIFY_URL, 'reqReserved' => ' 透传信息');
// 签名
sign($params);
echo "请求:" . getRequestParamString($params);
$log->LogInfo("后台请求地址为>" . SDK_BACK_TRANS_URL);
// 发送信息到后台
$result = sendHttpRequest($params, SDK_BACK_TRANS_URL);
$log->LogInfo("后台返回结果为>" . $result);
echo "应答:" . $result;
//返回结果展示
$result_arr = coverStringToArray($result);
echo verify($result_arr) ? '验签成功' : '验签失败';
?>