【发布时间】:2011-10-19 14:39:48
【问题描述】:
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
是否 POST 数组:
$postdata = array(
'send_email' => $_REQUEST['send_email'],
'send_text' => $_REQUEST['send_text']);
如何将单个数组元素获取到单个 PHP var?
POST数据处理器页面的一部分:
...
$message = $_REQUEST['postdata']['send_text'];
...
怎么了?
【问题讨论】:
-
你能试着澄清一下你遇到的问题吗?您是否收到任何错误消息?还是与另一端的脚本有关,即您要向其发送数据的页面的问题?
-
POST 数据处理器什么也没显示,它什么也没收到。
-
...如果你
print_r($_REQUEST);,你会得到什么?