Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从API回调url中查找值_Php_Codeigniter - Fatal编程技术网

Php 从API回调url中查找值

Php 从API回调url中查找值,php,codeigniter,Php,Codeigniter,我正在使用API在我的网站上发送短信。根据他们的文档,API结构如下所示: http://example.com/api/swsend.asp?username=xxxx&password=xxxx&sender=senderId&sendto=919xxxx,919xxxx&message=hello&dlrUrl=http://yourServer_Url?logID=$logID$%26phNo=$phNO$%26result=$result$

我正在使用API在我的网站上发送短信。根据他们的文档,API结构如下所示:

http://example.com/api/swsend.asp?username=xxxx&password=xxxx&sender=senderId&sendto=919xxxx,919xxxx&message=hello&dlrUrl=http://yourServer_Url?logID=$logID$%26phNo=$phNO$%26result=$result$  
public function sendMessageCallback() {        

    $responseBody = file_get_contents('php://input');  

    $data = array('value' => $responseBody, 'date' => date('Y-m-d h:i:s'));
    $this->db->insert('test1', $data);
}
消息发送部分正常。但我对回调url感到困惑。我的回调函数如下:

http://example.com/api/swsend.asp?username=xxxx&password=xxxx&sender=senderId&sendto=919xxxx,919xxxx&message=hello&dlrUrl=http://yourServer_Url?logID=$logID$%26phNo=$phNO$%26result=$result$  
public function sendMessageCallback() {        

    $responseBody = file_get_contents('php://input');  

    $data = array('value' => $responseBody, 'date' => date('Y-m-d h:i:s'));
    $this->db->insert('test1', $data);
}
因此,我的api调用类似于
http://example.com/api/swsend.asp?username=xxxx&password=xxxx&sender=senderId&sendto=919xxxx,919xxxx&message=hello&dlrUrl=http://example.in/API/sendMessageCallback


但没有任何内容写入数据库

我想您的问题在于PHP配置

检查服务器是否允许您使用文件函数打开远程url(php.ini“allow\u url\u fopen”设置必须为“true”)


如果允许,那么您可以尝试PHP cURL。

您是否尝试过
var\u dump($responseBody)
?如果您已经完成了,并且得到了正确的结果,请尝试在database.php中将db_debug转换为truefile@Alex我的网站已经上线了。所以我不能打开调试选项。这就是本地开发的目的。。。在那里做。如果您不能,那么我不确定您希望我们如何帮助您调试。我认为var\u转储是您所期望的,或者您不能也这样做吗?
var\u转储($responseBody)
prints
string(0)”“
这就是您的问题;)找出api调用没有返回任何内容的原因。通常获取内容
http://someapi.com/api?blah
使用curl(API通常返回类似于json的内容),然后您可以将该数据整合并输入到数据库中。由于我没有关于您正在使用的api的信息,我无法说明如何访问其数据,但我怀疑post是一种方式。