如何解析字符串以通过 ADB 发送短信

How to parse string for send SMS text message via ADB

我正在尝试通过 ADB 终端命令发送短信。

$message = "Joe Doe. We find a provider for your request, touch the link below for see more details.
https://massasistencia.com/detalles-cliente/23"

exec('adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+541156409605" s16 "null" s16 "' .$message. '" s16 "null" s16 "null"')

收到的消息只说 "Joe"

如果我只发送 link 短信就可以到达。 如果我执行 str_replace 到 "Joe Doe" 将“”替换为“-”,只发送名称,消息到达正常。

我认为问题出在空格 " "。

这是我正在使用的命令行,SMS 到达,因此命令有效,问题出在消息本身。

adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+541156409958" s16 "null" s16 "Hi" s16 "null" s16 "null"

您需要在邮件中的每个 space 字符前添加 斜杠字符 (\)。 以下命令将只发送 Joe:

 adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+541156409958" s16 "null" s16 "Joe Doe. hello" s16 "null" s16 "null"

以下命令将发送 Joe Doe。你好:

adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+541156409958" s16 "null" s16 "Joe\ Doe.\ hello" s16 "null" s16 "null"

您不需要在邮件中的每个 space 字符前添加斜线字符 ()。 这不是暴徒生活的工作吗?? 尝试用单引号将您的 SMS 正文括起来,您就大功告成了。

adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+541156409958" s16 "null" s16 "'Joe Doe. hello'" s16 "null" s16 "null"