0

PHP 代码文件:sms1.php 位于http://techmentry.com/sms1.php(请访问链接并查看以下代码的输出)。

<?php
//Variables to POST
$user = "HIDDEN";
$password = "HIDDEN";
$mobiles = "919999999999";
$message = "test";
$sender = "HIDDEN";

//Initialize CURL data to send via POST
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com/example.php");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&

password=$password&
mobiles=$mobiles&
message=$message&
sender=$sender"
);

//Execute CURL command and return into variable $result
$result = curl_exec($ch);

//Do stuff
echo "$result"
?>

我期望的输出是:上面的代码应该处理这个 URL:URL HIDDEN,然后返回一个消息 ID 或适当的错误代码。

但是我得到的输出超出了我的预期!甚至没有错误日志。请帮我 :)

4

1 回答 1

0

您获得了代码,但您也获得了来自服务器的完整响应,包括 HTTP 标头。

我得到:

HTTP/1.1 200 OK
Date: Wed, 24 Jul 2013 12:24:01 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: max-age=60, private, proxy-revalidate
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 8
Content-Type: text/html
Set-Cookie: PHPSESSID=c9bfcf7ddd3fff9d0a05b34541fbf0a9; expires=Wed, 24-Jul-2013 16:24:01 GMT; path=/

code 105

尝试删除此行:

curl_setopt($ch, CURLOPT_HEADER, 1);
于 2013-07-24T12:25:42.690 回答