【发布时间】:2011-09-05 18:36:40
【问题描述】:
我需要阅读使用 POST 操作类型进行提交的表单的结果。那么,我是否可以将通过 GET 变量获得的变量转换为 POST,然后我可以使用 file_get_contents() 简单地读取内容。
如果可能,请帮助我使用此方法或通过其他方法获取数据。
【问题讨论】:
我需要阅读使用 POST 操作类型进行提交的表单的结果。那么,我是否可以将通过 GET 变量获得的变量转换为 POST,然后我可以使用 file_get_contents() 简单地读取内容。
如果可能,请帮助我使用此方法或通过其他方法获取数据。
【问题讨论】:
file_get_contents可以通过stream_context_create来执行POST请求:
$options = array('http'=>array(
'method'=>'POST',
'header'=>'Content-type: application/x-www-form-urlencoded',
'content'=>'var1=a&var2=b'
)
);
echo file_get_contents('http://somesite.com/someform/', false, stream_context_create($options));
【讨论】:
var p = document.location.href; var p_1 = p.split("="); var req = p_1[1];