本文整理匯總了PHP中HttpClient::buildQueryString方法的典型用法代碼示例。如果您正苦於以下問題:PHP HttpClient::buildQueryString方法的具體用法?PHP HttpClient::buildQueryString怎麽用?PHP HttpClient::buildQueryString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HttpClient
的用法示例。
在下文中一共展示了HttpClient::buildQueryString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: customHttpClient
function customHttpClient($SERVER, $PATH, $COOKIES, $PARAMS)
{
//return;//return '{"resHeader":{"backUrl":"","flag":"0","msg":"訪問失敗"}}';
//到遠程服務器查詢登錄狀態
include_once dirname(__FILE__) . '/httpclient.inc.php';
try {
$client = new HttpClient($SERVER);
$client->timeout = 10;
$client->setCookies($COOKIES);
$client->setPersistCookies(true);
$postURL = $PATH;
customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", getHexDecode($client->buildQueryString($PARAMS)));
if (!$client->post($postURL, $PARAMS)) {
customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", "\nPUT SERVER:" . $SERVER . "" . $PATH . "\nFAILD1");
return '{"resHeader":{"backUrl":"","flag":"0","msg":"訪問失敗1"}}';
}
} catch (Exception $e) {
customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", "\nPUT SERVER:" . $SERVER . "" . $PATH . "\nFAILD2");
return '{"resHeader":{"backUrl":"","flag":"0","msg":"訪問失敗2"}}';
}
$response = $client->getContent();
customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", "\nPUT SERVER:" . $SERVER . "" . $PATH . "\nPUT COOKIES:" . (is_array($COOKIES) ? var_export($COOKIES, true) : '') . "\nPUT DATA:" . (is_array($PARAMS) ? var_export($PARAMS, true) : $PARAMS) . "\nGET DATA:" . iconv('GBK', 'UTF-8', $response));
return iconv('GBK', 'UTF-8', $response);
}
示例2: eposSale
function eposSale(array $bizArray, $actionURL, $merchantKey, $logName)
{
// 調用簽名函數生成簽名串
$ReqHmacString = getReqHmacString($bizArray, $logName, $merchantKey);
// 組成請求串
$actionHttpString = HttpClient::buildQueryString($bizArray) . "&pr_NeedResponse=1" . "&hmac=" . $ReqHmacString;
// echo $actionURL."?".$actionHttpString;exit;
// 記錄發起支付請求的參數
logurl("發起請求", $actionURL . "?" . $actionHttpString, $logName);
// 發起支付請求
$pageContents = HttpClient::quickPost($actionURL, $actionHttpString);
if ($GLOBALS['uid'] == '20310462') {
echo $pageContents . "<br>";
}
// 記錄收到的提交結果
logurl("請求回寫", $pageContents, $logName);
$result = explode("\n", $pageContents);
for ($index = 0; $index < count($result); $index++) {
$result[$index] = trim($result[$index]);
if (strlen($result[$index]) == 0) {
continue;
}
$aryReturn = explode("=", $result[$index]);
$sKey = $aryReturn[0];
$sValue = $aryReturn[1];
if ($sKey == "r0_Cmd") {
$r0_Cmd = $sValue;
} elseif ($sKey == "r1_Code") {
$r1_Code = $sValue;
} elseif ($sKey == "r2_TrxId") {
$r2_TrxId = $sValue;
} elseif ($sKey == "r6_Order") {
$r6_Order = $sValue;
} elseif ($sKey == "errorMsg") {
$errorMsg = $sValue;
} elseif ($sKey == "hmac") {
$hmac = $sValue;
}
/* else{
return $result[$index];
} */
}
$hmac = iconv("UTF-8", "GB2312", $hmac);
// 進行校驗碼檢查 取得加密前的字符串
$sbOld = "";
// 加入業務類型
$sbOld = $sbOld . $r0_Cmd;
// 加入支付結果
$sbOld = $sbOld . $r1_Code;
// 加入易寶支付交易流水號
$sbOld = $sbOld . $r2_TrxId;
// 加入商戶訂單號
$sbOld = $sbOld . $r6_Order;
$sNewString = HmacMd5($sbOld, $merchantKey, $logName);
logurl("訂單號:" . $r6_Order, "本地生成HMAC:" . $sNewString . "返回HMAC:" . $hmac, $logName);
$uid = substruid($r6_Order, 14);
$money = $bizArray['p3_Amt'];
global $_MooClass, $dbTablePre;
$sql_getpayid = "SELECT max(id) id FROM {$dbTablePre}payment_new WHERE order_id='{$r6_Order}'";
$getpayid = $_MooClass['MooMySQL']->getOne($sql_getpayid, true);
$id = $getpayid['id'];
$sql_p = "SELECT pay_service FROM {$dbTablePre}payment_new WHERE id='{$id}'";
$payservice = $_MooClass['MooMySQL']->getOne($sql_p, true);
// if($money=='1899'){
// $attach='0';
// }elseif($money=='1399'){
// $attach='1';
// }elseif($money=='1399.00'){
// $attach='2';
// }else{
// $attach='1';
// }
//
if ($payservice['pay_service'] == '0') {
$attach = '0';
} elseif ($payservice['pay_service'] == '1' || $payservice['pay_service'] == '3') {
$attach = '1';
} elseif ($payservice['pay_service'] == '2') {
$attach = '2';
} else {
$attach = '1';
}
if ($GLOBALS['uid'] == '20310462') {
echo $sNewString;
exit;
}
// 校驗碼正確
if ($sNewString == $hmac) {
if ($r1_Code == "1") {
logurl("請求成功", "本地生成HMAC:" . $sNewString . "返回HMAC:" . $hmac, $logName);
//返回信息 數組表示
$paytime = date("Y.m.d H:i:s");
$payurl = array('pay' => '1', 'out_trade_no' => $r6_Order, 'paytime' => $paytime, 'bank_type' => '易寶支付', 'trade_state' => '0', 'get_img' => '05.gif', 'img' => $attach, 'total_fee' => $bizArray['p3_Amt'], 'uid' => $uid);
//會員ID
$payurl = implode(',', $payurl);
$payurl = $payurl . ',yeepay';
header("Location:./../../index.php?n=payment&h=payreturnurl&payurl=" . $payurl);
return;
} elseif ($r1_Code == "66") {
$errorinfo = iconv("GB2312", "UTF-8", "訂單金額過小!");
//.........這裏部分代碼省略.........