canyin-project/ybcy/models/common/SanSong.php

51 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2024-11-01 16:07:54 +08:00
<?php
namespace app\models\common;
use Yii;
use yii\base\Model;
use yii\db\ActiveRecord;
class SanSong {
public static function request_post($url = '', $post_data) {
if (empty($url) || empty($post_data)) {
return false;
}
$postUrl = $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$postUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public static function generateSignature($data, $appSecrty) {
//return strtoupper(md5($partnerNo.$orderNo.$senderMobile.$key));
//1.升序排序
ksort($data);
//2.字符串拼接
$args = "";
foreach ($data as $key => $value) {
$args.=$key.$value;
}
$args = $appSecrty.$args;
//3.MD5签名,转为大写
$sign = strtoupper(md5($args));
return $sign;
}
}