--------------------
";
var_dump($url, $body);
echo "
--------------------
";
}
$output = curl_exec($ch);//运行curl
curl_close($ch);
return json_decode($output, true);
}
public static function getOpenBodySig($body, $echo_ = false)
{
$appid = self::$appid;
$appkey = self::$appkey;
$timestamp = date("YmdHis", time());
$nonce = md5(uniqid(microtime(true), true));
$str = bin2hex(hash('sha256', $body, true));
$signature = base64_encode(hash_hmac('sha256', "$appid$timestamp$nonce$str", $appkey, true));
$authorization = "OPEN-BODY-SIG AppId=\"$appid\", Timestamp=\"$timestamp\", Nonce=\"$nonce\", Signature=\"$signature\"";
if ($echo_) {
echo "
--------------------
";
var_dump($authorization);
echo "
--------------------
";
}
return $authorization;
}
}