C#微信开发:基础类之WeiXinConst

本篇文章一起了解C#微信开发:基础类之WeiXinConst

发过程中需要用的的公众号信息在这里配置,此外需要用到的Url信息无需更改。

/// 
/// 微信 需要用到的Url、Json常量
/// 
public class WeiXinConst
{
    #region Value Const
 
    /// 
    /// 微信开发者 AppId
    /// 
    public const string AppId = "你的AppId";
 
 
    /// 
    /// 微信开发者 Secret
    /// 
    public const string Secret = "你得Secret";
 
 
    /// 
    /// V2:支付请求中 用于加密的秘钥Key,可用于验证商户的唯一性,对应支付场景中的AppKey
    /// 
    public static string PaySignKey = "V2.PaySignKey";
 
 
    /// 
    /// V2:财付通签名key
    /// V3:商户支付密钥 Key。登录微信商户后台,进入栏目【账户设置】 【密码安全 】【API 安全】 【API 密钥】 ,进入设置 API 密钥。
    /// 
    public const string PartnerKey = "PartnerKey";
 
    /// 
    /// 商户号
    /// 
    public const string PartnerId = "PartnerId";
 
 
    /// 
    /// 百度地图Api  Ak
    /// 
    public const string BaiduAk = "BaiduAk";
 
    /// 
    /// 用于验证 请求 是否来自 微信
    /// 
    public const string Token = "Token";
 
    /// 
    /// 证书文件 路径
    /// 
    public const string CertPath = @"E:certapiclient_cert.pem";
 
 
    /// 
    /// 证书文件密码(默认为商户号)
    /// 
    public const string CertPwd = "111";
 
    #endregion
 
    #region Url Const
 
    #region AccessTokenUrl
 
    /// 
    /// 公众号 获取Access_Token的Url(需Format  0.AppId 1.Secret)
    /// 
    private const string AccessToken_Url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";
 
    /// 
    /// 公众号 获取Token的Url
    /// 
    public static string WeiXin_AccessTokenUrl { get { return string.Format(AccessToken_Url, AppId, Secret); } }
 
    #endregion
 
    #region 获取用户信息Url
 
    /// 
    /// 根据Code 获取用户OpenId Url
    /// 
    private const string User_GetOpenIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code";
 
    /// 
    /// 根据Code 获取用户OpenId的Url 需要Format 0.code
    /// 
    public static string WeiXin_User_OpenIdUrl { get { return string.Format(User_GetOpenIdUrl, AppId, Secret, "{0}"); } }
 
    /// 
    /// 根据OpenId 获取用户基本信息 Url(需要Format0.access_token 1.openid)
    /// 
    public const string WeiXin_User_GetInfoUrl = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN";
 
    #endregion
 
    #region OAuth2授权Url
 
    /// 
    /// OAuth2授权Url,需要Format0.AppId  1.Uri  2.state
    /// 
    private const string OAuth2_Url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state={2}#wechat_redirect";
 
    /// 
    /// OAuth2授权Url,需要Format  0.Uri  1.state
    /// 
    public static string WeiXin_User_OAuth2Url { get { return string.Format(OAuth2_Url, AppId, "{0}", "{1}"); } }
 
    #endregion
 
    #region QrCode Url
 
    /// 
    /// 创建获取QrCode的Ticket Url  需要Format 0 access_token
    /// 
    public const string WeiXin_Ticket_CreateUrl = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}";
 
    /// 
    /// 获取二维码图片Url,需要Format 0.ticket
    /// 
    public const string WeiXin_QrCode_GetUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={0}";
 
    #endregion
 
    #region Baidu 逆地理编码Url
 
    /// 
    /// 经纬度  逆地理编码 Url  需要Format 0.ak  1.经度  2.纬度
    /// 
    private const string BaiduGeoCoding_ApiUrl = "http://api.map.baidu.com/geocoder/v2/?ak={0}&location={1},{2}&output=json&pois=0";
 
    /// 
    /// 经纬度  逆地理编码 Url  需要Format 0.经度  1.纬度
    /// 
    public static string Baidu_GeoCoding_ApiUrl
    {
        get
        {
            return string.Format(BaiduGeoCoding_ApiUrl, BaiduAk, "{0}", "{1}");
        }
    }
 
    #endregion
 
    #region Menu Url
 
    /// 
    /// 创建菜单Url 需要Format 0.access_token
    /// 
    public const string WeiXin_Menu_CreateUrl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}";
 
    /// 
    /// 获取菜单Url 需要Format 0.access_token
    /// 
    public const string WeiXin_Menu_GetUrl = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token={0}";
 
    /// 
    /// 删除菜单Url 需要Format 0.access_token
    /// 
    public const string WeiXin_Menu_DeleteUrl = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token={0}";
 
 
    #endregion
 
    #region 支付相关Url
 
    /// 
    /// 生成预支付账单Url ,需替换 0 access_token
    /// 
    public const string WeiXin_Pay_PrePayUrl = "https://api.weixin.qq.com/pay/genprepay?access_token={0}";
 
    /// 
    /// 订单查询Url ,需替换0 access_token
    /// 
    public const string WeiXin_Pay_OrderQueryUrl = "https://api.weixin.qq.com/pay/orderquery?access_token={0}";
 
    /// 
    /// 发货通知Url,需替换 0 access_token
    /// 
    public const string WeiXin_Pay_DeliverNotifyUrl = "https://api.weixin.qq.com/pay/delivernotify?access_token={0}";
 
    #region 统一支付相关Url (V3接口)
 
    /// 
    /// 统一预支付Url
    /// 
    public const string WeiXin_Pay_UnifiedPrePayUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder";
 
    /// 
    /// 订单查询Url
    /// 
    public const string WeiXin_Pay_UnifiedOrderQueryUrl = "https://api.mch.weixin.qq.com/pay/orderquery";
 
    /// 
    /// 退款申请Url
    /// 
    public const string WeiXin_Pay_UnifiedOrderRefundUrl = "https://api.mch.weixin.qq.com/secapi/pay/refund";
 
    #endregion
 
 
    #endregion
 
    #endregion
 
    #region Json Const
 
    /// 
    /// 获取二维码 所需Ticket 需要上传的Json字符串(需要Format 0.scene_id)
    /// 
    /// scene_id场景值ID  永久二维码时最大值为100000(目前参数只支持1--100000)
    public const string WeiXin_QrCodeTicket_Create_JsonString = "{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id":{0}}}}";
 
    #endregion
 
}

以上就是C#微信开发:基础类之WeiXinConst的详细内容,更多请关注php中文网其它相关文章!

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注