/// <summary> /// 创建二维码ticket /// </summary> /// <param name="isTemp"></param> /// <param name="scene_id"></param> /// <param name="appId"></param> /// <param name="appSecret"></param> /// <returns></returns> public static QRCodeTicket CreateQRCode(bool isTemp, int scene_id, string appId, string appSecret) { string url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="; string access_token = GetAccessToken(appId, appSecret); url = url + access_token; var action_name = isTemp ? "QR_SCENE" : "QR_LIMIT_SCENE"; string data; if (isTemp) { data = "{\"expire_seconds\": 1800, \"action_name\": \"QR_SCENE\", \"action_info\": {\"scene\": {\"scene_id\":" + scene_id + "}}}"; } else { data = "{\"action_name\": \"QR_LIMIT_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": " + scene_id + "}}}"; } var json = Util.HttpPost2(url, data); if (json.IndexOf("ticket") > 0) { return(Util.JsonTo <QRCodeTicket>(json)); } else { QRCodeTicket tk = new QRCodeTicket(); tk.error = Util.JsonTo <ReturnCode>(json); return(tk); } }
/// <summary> /// 创建二维码ticket /// </summary> /// <param name="scene_str"></param> /// <param name="appId"></param> /// <param name="appSecret"></param> /// <returns></returns> public static QRCodeTicket CreateQRCode2(string scene_str, string appId, string appSecret) { string url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="; string access_token = GetAccessToken(appId, appSecret); url = url + access_token; string data; data = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\":\"" + scene_str + "\"}}}"; var json = Util.HttpPost2(url, data); if (json.IndexOf("ticket") > 0) { return(Util.JsonTo <QRCodeTicket>(json)); } else { QRCodeTicket tk = new QRCodeTicket(); tk.error = Util.JsonTo <ReturnCode>(json); return(tk); } }