codeigniter - 无法使用 twilio 接收传入的短信正文单个字
问题描述
我在我的网站上使用 Twilio PHP API 发送和接收短信。我成功发送短信,但我无法接收来自传入短信的单个单词。假设客户在我的 twilio 号码中发送了一条短信,例如 =“我要回家了“现在我想从那行中取出两个词,例如 i,home。我可以用这个代码吗
<?php
$msg1 = $_REQUEST['Body[0]'];
$msg2 = $_REQUEST['Body[2]'];
header('Content-Type: text/xml');
?>
我对吗?或者我应该改变什么
解决方案
Twilio developer evangelist here.
The issue here is that you have the square brackets inside the string. Try this instead:
<?php
$body = $_REQUEST['Body'];
$msg1 = $body[0];
$msg2 = $body[2];
header('Content-Type: text/xml');
?>
推荐阅读
- java - Kotlin Lint 测试失败,即使它在生产中有效
- reactjs - 如何设置 customvalidity 以在其中包含链接?
- java - java.lang.IllegalArgumentException:要发送的键应为非空 CharSequence
- java - Springboot 角色身份验证不起作用。我无法访问特定路径,
- java - 如何在 Spring Security 中将 PasswordEncoder 添加到 JdbcUserDetailsManager 中?
- neo4j - 在 Neo4j 中使用 apoc.load.json() 时如何从 Json 文件中读取关系?
- macos - 找不到 docker 命令
- python - 如果 self.maxsize > 0: TypeError: '>' not supported 在 'NoneType' 和 'int' 的实例之间
- javascript - 为什么不能导入或需要 peerDependency,即使它存在于父模块中?
- python - Python从导入的模块调用函数导致权限错误