【发布时间】:2016-02-04 06:16:09
【问题描述】:
请看下面的代码:
$url='https://www.test.com/test.php';
$post='?field1=1&field2=2&filed3'; // no need array text as is
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_exec ($ch);
curl_close ($ch)
应该是简单的代码,我用作参考http://curl.haxx.se/libcurl/php/examples/simplepost.html
我通过替换为变量来修改代码。
我需要将数据发送到属于第三方的远程服务器。对方的服务器有数据库。当我手动将www.test.com/test.php?field1=1&field2=2&filed3 复制到网络浏览器中时,数据保存到其他服务器的数据库中并在浏览器屏幕上响应{"Code":15,"Msg":null"},这意味着数据发送正确。尝试通过 PHP 脚本发送时,未保存在远程数据库中的数据也未收到响应消息。
【问题讨论】:
-
什么不起作用?发生了什么,你有什么期待?
-
请用所有这些信息更新您的答案