91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-02-01
  • 語言: C#
  • 標簽: 小程序??卡券??

資源簡介

在做小程序領券開發時,遇到了很多坑,微信的文檔你們懂的,有點反人類。其中相信做小程序卡券遇到最多的應該是“簽名錯誤”。完全按照文檔來還是簽名錯誤!生成的簽名與簽名校驗工具一致還是簽名錯誤。。。各種各樣的坑搞到焦頭爛額,所以我弄好后,寫了一個可正常執行的demo,你們可以對照著看,看自己哪里寫錯了。(包含了小程序代碼,以及c#的后臺代碼。代碼50多行,不多)

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Net;
using?System.Net.Security;
using?System.Security.Cryptography.X509Certificates;
using?System.Text;
using?System.Web;


namespace?CySoft.Utility
{

????public?sealed?class?WebUtils
????{
????????private?int?_timeout?=?150000;
????????private?string?_charset?=?“utf-8“;
????????private?string?_format?=?“hash“;

????????public?WebUtils()
????????{

????????}

????????public?WebUtils(string?charset?int?timeout)
????????{
????????????this._charset?=?charset;
????????????this._timeout?=?timeout;
????????}

????????///?
????????///?執行HTTP?GET請求。
????????///?

????????///?請求地址
????????///?請求參數
????????///?編碼字符集
????????///?HTTP響應
????????public?string?DoGet(string?url?IDictionary?parameters)
????????{
????????????if?(parameters?!=?null?&&?parameters.Count?>?0)
????????????{
????????????????url?=?url.Contains(“?“)???string.Format(“{0}&{1}“?url?BuildGetQuery(parameters))?:
????????????????????string.Format(“{0}?{1}“?url?BuildGetQuery(parameters));
????????????}

????????????HttpWebRequest?req?=?GetWebRequest(url?“GET“);
????????????req.ContentType?=?“application/x-www-form-urlencoded;charset=utf-8“;

????????????HttpWebResponse?rsp?=?(HttpWebResponse)req.GetResponse();
????????????//Encoding?encoding?=?Encoding.GetEncoding(rsp.CharacterSet);
????????????//return?GetResponseAsString(rsp?encoding);
????????????string?ret?=?GetRequestStream(rsp);
????????????return?ret;
????????}

????????///?
????????///?組裝普通文本請求參數。(不排序)
????????///?

????????///?Key-Value形式請求參數字典
????????///?URL編碼后的請求數據
????????public?static?string?BuildGetQuery(IDictionary?parameters)
????????{
????????????IEnumerator>?sortedParams?=?parameters.GetEnumerator();
????????????StringBuilder?builder?=?new?StringBuilder();
????????????while?(sortedParams.MoveNext())
????????????{
????????????????string?key?=?sortedParams.Current.Key;
????????????????string?value?=?sortedParams.Current.Value;
????????????????//?忽略參數名或參數值為空的參數
????????????????if?(!string.IsNullOrWhiteSpace(key)?&&?!string.IsNullOrWhiteSpace(value))
????????????????????builder.AppendFormat(“{0}={1}&“?key?HttpUtility.UrlEncode(value?Encoding.GetEncoding(“utf-8“)));
????????????}

????????????string?content?=?builder.Remove(builder.Length?-?1?1).ToString();
????????????return?content;
????????}

????????public?string?GetRequestStream(HttpWebResponse?rsp)
????????{
????????????StringBuilder?builder?=?new?StringBuilder();
????????????Stream?stream?=?null;
????????????try
????????????{
????????????????stream?=?rsp.GetResponseStream();
????????????????int?count?=?0;
????????????????byte[]?buffer?=?new?byte[102

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3237??2019-01-28?15:50??NET(C#)小程序卡券demo.txt

?????文件??????25390??2019-01-28?15:58??WebUtils.cs

-----------?---------??----------?-----??----

????????????????28627????????????????????2


評論

共有 條評論