DEMO:Factor/Mobile - 運(yùn)營商二要素
代碼示例
/*****************
* 加密請求 示例代碼
******************/
//appid參數(shù) appkey參數(shù)在 身份認(rèn)證-創(chuàng)建/管理AppID中獲取
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$timestamp = time(); //獲取當(dāng)前時間戳
$name = '***'; //待驗(yàn)證用戶姓名
$mobile = '152********'; //待驗(yàn)證用戶 電話號碼
$post_data = array(
'timestamp' => $timestamp,
'name' => $name,
'appkey' => $appkey,
'mobile' => $mobile,
);
//生成簽名
ksort($post_data);
reset($post_data);
$post_data['signature'] = hash('sha256', http_build_query($post_data));
$post_data['appid'] = $appid;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://tpa.mysubmail.com/factor/mobile",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($post_data),
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded"),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}