开发者

How to submit POST data with DOMDocument

I want to submit POST data using the DOMDocument class (DOMDocument::loadHTMLFile() to be precise) to simulate a html form using the post method being submitted.

For that purpose I tried to set my params using stream_context_set_default() but somehow that won't work:

<?php
$default_opts = array(开发者_StackOverflow中文版
  'http'=>array(
     'method'=>"GET",
     'header'=>"Accept-language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3",
     'content'=>'param=value'
   )
);
stream_context_set_default($default_opts);

$doc = new DOMDocument();
$doc->loadHTMLFile('http://127.168.2.1/path/to/file/test_post.php');

echo $doc->saveXML();
?>

Am I missing something or is there simply no way to do that? If so, is there another way to do that with the DOMDocument class or do i have to use another mechanism like curl or fsockopen()?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜