一、检测数据的两种方式:
1.人工筛选,将要验证的号码输出到文件中,以逗号分隔。再将文件中的号码粘贴到iMessage客户端的地址栏,iMessage客户端会自动逐个检验该号码是否为iMessage账号,检验速度视网速而定。红色表示不是iMessage账号,蓝色表示iMessage账号。
2.编写脚本控制Mac os/iphone上自带的iMessage应用进行验证(全自动检测,无需人工干预),类似于群发iMessage;发送一条iMessage之后,如果捕获到发送失败的异常则不是iMessage账号,捕获到发送成功则把数据保存下来。
二、脚本或app对指定数据全自动过滤
1.电脑版检测数据是否imessages(自动检测导入的txt数据,蓝色的手机号数据自动保存,有意者联系)
示例检测脚本代码:
startApp()on clickOk()tell application "Messages" to activatetell application "System Events"tell process "Messages"tell window 1entire contentsend tellend tellend tell
end clickOkon startApp()tell application "Finder" to activatetell application "Finder"set chosenfile to (choose file) --选择制定需要检测的数据例如: phone.txtend telltell application "Messages"tell application "Messages" to activateset phoneData to read chosenfileset cards to paragraphs of phoneDatarepeat with phone in cards--set msgText to (my AppendFace(" "))-- 假如字符串不是11位,则草率判定不是手机号set num to the length of phoneif (num > 0) then--执行发送my sendMsg(phone, ".")delay 1# 及时删除多余的消息set chatNum to (get count of chat)if chatNum is greater than 1 thenmy deleteMsg(chatNum, phone)end ifend ifend repeatend tell
end startApp# 发送信息
on sendMsg(phone, msg)tell application "System Events"tell process "Messages"tell window 1delay 0.2key code 55 & 45--核心代码,省略.........end tellend tellend tell
end sendMsg# 删除信息
on deleteMsg(maxNum, thisphone)tell application "Messages" to activatetell application "System Events"tell process "Messages"tell window 1repeat maxNum timesdelay 0.2 -- 延时0.5秒click row 1 of table 1 of scroll area 1 of splitter group 1 --选中第一个会话delay 0.2 -- 延时0.5秒click menu item "删除对话…" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events"--激活右键菜单中的删除对话delay 0.2 -- 延时0.5秒tryclick button "删除" of sheet 1--对启用了imessage功能的手机号码进行记录my WritePhone(thisphone)end tryend repeatend tellend tellend tell
end deleteMsg-- 记录有效手机号
on WritePhone(the_phone)set num to the length of the_phoneif (num > 0) thenset fileName to date string of (current date)set logFilePath to my current_folder_path() & "send/检测成功的数据.txt"set this_file to (POSIX file logFilePath as string)set this_story to the_phone & "
"tryset fp to open for access this_fileset myText to read fpif (myText does not contain the_phone) thenmy write_to_file(this_story, this_file, true, true)end ifon errormy write_to_file(this_story, this_file, true, true)end tryend if
end WritePhone-- 写入文件
-- this_data(文本内容,string)
-- target_file(文件路径,string)
-- append_data(是否拼接,boolean)
-- append_end(是否从后面拼接,boolean)
on write_to_file(this_data, target_file, append_data, append_end)tryset the target_file to the target_file as textset the open_target_file to ¬open for access file target_file with write permissionif append_data is false thenset eof of the open_target_file to 0write this_data to the open_target_file starting at eofelse if append_end is false then-- 1、读取原来内容;-- 2、清空文件,写入新内容;-- 3、在新内容后面拼接原始内容tryset fp to open for access target_fileset myText to read fpset eof of the open_target_file to 0write this_data to the open_target_file starting at eofwrite myText to the open_target_file starting at eofon errorwrite this_data to the open_target_file starting at eofend tryelsewrite this_data to the open_target_file starting at eofend ifclose access the open_target_filereturn target_fileon errortryclose access file target_fileend tryreturn falseend try
end write_to_file-- 获取当前文件的父文件夹路径
on current_folder_path()set UnixPath to POSIX path of ((path to me as text) & "::")return UnixPath
end current_folder_path
检测脚本运行:
2.手机版检测数据是否imessages(自动检测导入的txt数据,蓝色的数据自动保存,有意者联系)