Android之百度云推送(四)open_type is not valid报错error_code30602

Android之百度云推送(四)open_type is not valid报错error_code30602

参考

http://blog.youkuaiyun.com/xyzz609/article/details/52292870

在本地环境上实验。没问题,昨天发到生成环境了,居然报错

有信息吗?1
URL:[http://api.tuisong.baidu.com/rest/3.0/push/single_device]
params:[apikey=WnK9iAqBTaVKC9GnmGORSyWC&channel_id=3898756644656267390&device_type=3&msg=%7B%22title%22%3A%22%E5%B9%B4%E5%90%8E%E5%8F%91%E5%A4%A7%E6%B0%B4%E4%BA%86%E5%BC%80%E5%8F%91%22%2C%22description%22%3A%22%E8%8C%83%E5%BE%B7%E8%90%A8%E8%8C%83%E5%BE%B7%E8%90%A8%E5%8F%91%E7%94%9F%E5%9C%B0%E6%96%B9%E6%92%92%E6%97%A6%22%2C%22notification_builder_id%22%3A0%2C%22notification_basic_style%22%3A5%2C%22open_type%22%3A3%2C%22custom_content%22%3A%7B%22logStaffCode%22%3A%22zq%22%2C%22logStaffId%22%3A%22982985123456%22%2C%22logManagerId%22%3A%22422493%22%2C%22managerTypeId%22%3A%2249%22%2C%22logLatnId%22%3A%22-1%22%2C%22logAreaId%22%3A%221%22%2C%22H5Url%22%3A%22http%3A%2F%2F219.146.3.91%3A9001%2Fappserver%2Findex-ipad.html%22%7D%7D&msg_expires=3600&msg_type=1&sign=2e451e872c37a7a61203e63edde9d1be&timestamp=1472003593]
HttpStatusCode:[400]
Response:[{"request_id":3373849957,"error_code":30602,"error_msg":"Request Params Not Valid, open_type is not valid"}]

requestId: 3373849957, errorCode: 30602, errorMessage: Request Params Not Valid, open_type is not valid

没错我就是用的上一片的代码,抱这错,说来奇怪,我把他改成2 ,就不报错了,可是他到不了我们需要的指定页面了。。。

当时参考

http://blog.youkuaiyun.com/onepiece2/article/details/46422811
当open_type为1,点击通知后能够打开特定界面,并打开url,若没有指定url,则跳转到百度开发者官网
当open_type为2,点击通知后先打开特定的界面,但之后马上会打开应用包下入口页面,跳转到入口的页面
当open_type为3,点击通知后打开想要进入的页面

为什么会不行呢。open_type is not valid,这是为什么

研究百度文档可以自己进去看

http://developer.baidu.com/wiki/index.php?title=docs/cplat/push/faq

这里给你截图了,

这里写图片描述

看看消息格式居然open_type只有1和2

那我当时参考有问题?可是我本地测试没错啊

再仔细看,属性解释也之后1和2

这里写图片描述

我确定我测试过,1是打开网址2是打开应用

这里写图片描述

这个东西真是头大。。。不过还是得看官方文档

静下心来,你发现open_type=2时,pkg_content咱们没有写,难道是因为这?

答案是肯定的,百度下

http://blog.youkuaiyun.com/qingfeng812/article/details/51830149

如果没有写标准的intent uri格式,点击无法到达指定 activity;

     notification.put("open_type", 2);
     notification.put("pkg_content",        "#Intent;component=com.xzjmyk.pm.activity/.ui.message.uas.B2bMsgActivity;end"); 

终于成功了。。

我只能说

http://blog.youkuaiyun.com/xyzz609/article/details/52292870

里面的open_type=3是错的。。因为官网根本没有3

即使测试的时候没有错,也不建议使用,因为太坑了,,被老板骂了一上午。。

欢迎大家不懂得可以加群玩android不是梦 261403514咱们商讨一下

import requests import json import time import os from datetime import datetime COOKIE_FILE = "cookies.txt" #放ck,越多速度可以调越快 DATA_FILE = "data.txt" #放身份证和名字 PHONE_FILE = "phones.txt" #放手机号 REQUEST_INTERVAL = 1.5 #速度单位秒 MAX_RETRY = 3 #重试次数 RATE_LIMIT_WAIT = 1 #频率限制等待时间 class CookieManager: def __init__(self): self.cookies = [] self.failed_cookies = set() self.last_used_time = {} self.current_round_order = [] self.current_index = 0 try: self.load_cookies() except Exception as e: print(f"⚠️ 初始化警告: {str(e)}") if not self.cookies: self.add_new_cookie(first_time=True) def load_cookies(self): try: with open(COOKIE_FILE, "r", encoding="utf-8") as f: self.cookies = [line.strip() for line in f if line.strip()] if not self.cookies: print("⚠️ Cookie文件为空") else: print(f"✅ 已加载 {len(self.cookies)} 个有效Cookie") except FileNotFoundError: print("⚠️ Cookie文件不存在,将创建新文件") open(COOKIE_FILE, 'w').close() def get_cookie(self): valid_cookies = [c for c in self.cookies if c not in self.failed_cookies] while not valid_cookies: print("⚠️ 无可用Cookie,请添加新Cookie") if self.add_new_cookie(): valid_cookies = [c for c in self.cookies if c not in self.failed_cookies] else: raise Exception("用户取消输入,终止操作") current_valid_set = set(valid_cookies) current_round_set = set(self.current_round_order) if ( not self.current_round_order or current_valid_set != current_round_set or self.current_index >= len(self.current_round_order) ): sorted_cookies = sorted(valid_cookies, key=lambda x: self.last_used_time.get(x, 0)) self.current_round_order = sorted_cookies self.current_index = 0 selected = self.current_round_order[self.current_index] self.current_index += 1 self.last_used_time[selected] = time.time() return selected def mark_failed(self, cookie, reason=""): self.failed_cookies.add(cookie) print(f" 标记失效Cookie:{cookie[:15]}... 原因:{reason or '未知'}") def add_new_cookie(self, first_time=False): prompt = "请输入新Cookie" + ("(直接回车将退出程序)" if first_time else "(直接回车跳过)") new_cookie = input(prompt + ":").strip() if not new_cookie: if first_time: raise Exception("必须至少提供一个Cookie") return False if new_cookie not in self.cookies: self.cookies.append(new_cookie) with open(COOKIE_FILE, "a", encoding="utf-8") as f: f.write(new_cookie + "\n") print("✅ 新Cookie已添加") return True return False def extract_user_names(data): user_names = [] if isinstance(data, dict): for key, value in data.items(): if key == "userName": try: # 尝试UTF-8编码 user_name = str(value).encode('utf-8').decode('utf-8') except UnicodeError: # 如果编码失败,替换非UTF-8字符为* user_name = ''.join(c if ord(c) < 128 else '*' for c in str(value)) user_names.append(user_name) elif isinstance(value, (dict, list)): user_names.extend(extract_user_names(value)) elif isinstance(data, list): for item in data: user_names.extend(extract_user_names(item)) return user_names def handle_rate_limit(cookie_manager, current_cookie): print(f"× 触发频率限制,等待 {RATE_LIMIT_WAIT} 秒...") time.sleep(RATE_LIMIT_WAIT) cookie_manager.mark_failed(current_cookie, "频率限制") return cookie_manager.get_cookie() def make_request(url, headers, payload, cookie_manager): for attempt in range(MAX_RETRY): try: current_cookie = cookie_manager.get_cookie() headers['Cookie'] = current_cookie response = requests.post( url, headers=headers, json=payload, timeout=15 ) if "操作太快了" in response.text: current_cookie = handle_rate_limit(cookie_manager, current_cookie) continue response.raise_for_status() return response, None except requests.exceptions.HTTPError as e: if e.response.status_code in (401, 403): cookie_manager.mark_failed(current_cookie, f"HTTP {e.response.status_code}") if cookie_manager.add_new_cookie(): continue return None, f"HTTP错误: {str(e)}" except Exception as e: return None, f"请求失败: {str(e)}" finally: time.sleep(REQUEST_INTERVAL) return None, "超过最大重试次数" def query_associated_account(account, cookie_manager): url = "https://app.m.kuaishou.com/rest/wd/account/appeal/v2/find" headers = { 'User-Agent': "Mozilla/5.0 (Linux; Android 13; V2312A Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.212 KsWebView/1.8.121.802 (rel;r) Mobile Safari/537.36 Yoda/3.2.14-rc3 Kwai/13.3.40.41578 OS_PRO_BIT/64 MAX_PHY_MEM/7367 KDT/PHONE AZPREFIX/az4 ICFO/0 StatusHT/31 TitleHT/43 NetType/NR ISLP/0 ISDM/1 ISLB/1 locale/zh-cn DPS/10.212 DPP/68 SHP/2298 SWP/1080 SD/2.7 CT/0 ISLM/1", 'Content-Type': 'application/json' } payload = {"account": account, "findType": 3} response, error = make_request(url, headers, payload, cookie_manager) if error: return [], error try: json_data = response.json() if json_data.get("error_msg") == "当前输入信息未关联到任何账号,请检查后重试!": return [], "账号未关联" if json_data.get("error_msg"): return [], json_data["error_msg"] return list(set(extract_user_names(json_data))), None except json.JSONDecodeError: return [], "响应解析失败" def verify_id_card(id_card_number, id_card_name, cookie_manager, target_users): url = "https://app.m.kuaishou.com/rest/wd/account/appeal/v2/find" headers = { "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Kwai/13.1.10.9110 ISLP/0 StatusHT/59 KDT/PHONE iosSCH/0 TitleHT/44 NetType/WIFI ISDM/0 ICFO/0 locale/zh-Hans CT/0 Yoda/3.0.7 ISLB/0 CoIS/2 ISLM/0 WebViewType/WK BHT/102 AZPREFIX/az3", "Content-Type": "application/json" } payload = { "idCardNumber": id_card_number, "idCardName": id_card_name, "findType": 2 } response, error = make_request(url, headers, payload, cookie_manager) if error: return {"status": "error", "error": error} try: json_data = response.json() found_users = list(set(extract_user_names(json_data))) user_status = [] for user in found_users: if user in target_users: user_status.append(f"{user}✅✅✅") else: user_status.append(f"{user}❌❌❌") return { "status": "success", "user_status": user_status, "http_status": response.status_code } except Exception as e: return {"status": "error", "error": str(e)} def verify_phone(phone_number, cookie_manager, target_users): url = "https://app.m.kuaishou.com/rest/wd/account/appeal/v2/find" headers = { 'User-Agent': "Mozilla/5.0 (Linux; Android 13; V2312A Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/115.0.5790.166 Mobile Safari/537.36 KSSO/Android/13.3.40.41578", 'Content-Type': 'application/json' } payload = {"account": phone_number, "findType": 1} response, error = make_request(url, headers, payload, cookie_manager) if error: return {"status": "error", "error": error} try: json_data = response.json() if json_data.get("result") == 400010: return {"status": "error", "error": "Cookie已过期"} found_users = list(set(extract_user_names(json_data))) user_status = [] for user in found_users: if user in target_users: user_status.append(f"{user}✅✅✅") else: user_status.append(f"{user}❌❌❌") return { "status": "success", "user_status": user_status, "http_status": response.status_code } except Exception as e: return {"status": "error", "error": str(e)} def load_data_file(filename): try: with open(filename, "r", encoding="utf-8") as f: return True, [line.strip() for line in f if line.strip()] except FileNotFoundError: return False, f"{filename} 文件不存在" except Exception as e: return False, f"文件读取失败: {str(e)}" def get_target_users(cookie_manager): print("\n选择用户名输入方式:") print("1. 输入快手号自动获取关联账号") print("2. 直接输入用户名例如“不知名的情”") choice = input("请输入选项 (1/2): ").strip() target_users = [] if choice == '1': account = input("请输入快手号:").strip() users, error = query_associated_account(account, cookie_manager) if error: print(f"❌ 查询失败: {error}") return None target_users = users print("\n找到关联账号:" + ",".join(users).encode('utf-8', 'ignore').decode() if users else "未找到关联账号") elif choice == '2': users = input("请输入用户名(多个用逗号分隔): ").strip().split(',') target_users = [u.strip() for u in users if u.strip()] else: print("❌ 无效选项") return None if not target_users: print("❌ 未获取到有效目标用户") return None return target_users # In the process_id_verification function, modify the loop section: def process_id_verification(cookie_manager): print("\n" + "="*40) print("开始身份证核验流程...") target_users = get_target_users(cookie_manager) if not target_users: return status, id_data = load_data_file(DATA_FILE) if not status: print(f"❌ {id_data}") return successful_matches = [] total_items = len(id_data) completed = 0 for line in id_data: if not line.strip(): continue parts = line.split(maxsplit=1) if len(parts) != 2: print(f"无效数据格式:{line}") completed += 1 continue name, id_card = parts[0], parts[1] result = verify_id_card(id_card, name, cookie_manager, target_users) base_output = f"{name}-{id_card}-" if result["status"] != "success": error = result.get("error", "未知错误").split(":")[-1].strip() print(f"{base_output}{error}❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})") completed += 1 continue if result.get("user_status"): users_str = ",".join(result["user_status"]) final_output = f"{base_output}{users_str}" print(f"{final_output} (已完成 {completed+1}/{total_items}/{total_items-completed-1})") if any("✅" in s for s in result["user_status"]): successful_matches.append(final_output) else: print(f"{base_output}无关联账号❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})") completed += 1 print("\n" + "="*40) print("身份证核验结果(仅显示匹配项):") if successful_matches: for match in successful_matches: print(match.replace("✅", "\033[32m✅\033[0m").replace("❌", "\033[31m❌\033[0m")) else: print("无成功匹配记录") # Similarly, modify the process_phone_verification function: def process_phone_verification(cookie_manager): print("\n" + "="*40) print("开始手机号绑定查询...") target_users = get_target_users(cookie_manager) if not target_users: return status, phones = load_data_file(PHONE_FILE) if not status: print(f"❌ {phones}") return successful_matches = [] total_items = len(phones) completed = 0 for phone in phones: result = verify_phone(phone, cookie_manager, target_users) base_output = f"{phone}-" if result["status"] != "success": error = result.get("error", "未知错误").split(":")[-1].strip() print(f"{base_output}{error}❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})") completed += 1 continue if result.get("user_status"): users_str = ",".join(result["user_status"]) final_output = f"{base_output}{users_str}" print(f"{final_output} (已完成 {completed+1}/{total_items}/{total_items-completed-1})") if any("✅" in s for s in result["user_status"]): successful_matches.append(final_output) else: print(f"{base_output}无关联账号❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})") completed += 1 print("\n" + "="*40) print("手机号绑定结果(仅显示匹配项):") if successful_matches: for match in successful_matches: print(match.replace("✅", "\033[32m✅\033[0m").replace("❌", "\033[31m❌\033[0m")) else: print("无成功匹配记录") def main(): print("="*40) print("快手账号关联查询系统 v4.6") print("风月制作@fengyuettkx") print("频道https://t.me/fengyuexiaowo") try: cm = CookieManager() except Exception as e: print(f"❌ 初始化失败: {str(e)}") if "必须至少提供一个Cookie" in str(e): print("请创建cookies.txt文件或运行程序时添加Cookie") return print("\n请选择功能:") print("1. 身份证实名账号查询") print("2. 手机号绑定查询") choice = input("请输入选项 (1/2): ").strip() if choice == '1': process_id_verification(cm) elif choice == '2': process_phone_verification(cm) else: print("❌ 无效选项") if __name__ == "__main__": main()把访问文件目录放在/storage/emulated/0/
最新发布
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值