记录一下,留着以后看方便。
这是一个post请求并的便子,主要在系统内部用。
外部请求可能要求登录信息,但基本上体现了file_get_contents的用法。
function Post($url, $post = null)
{
$context = array();
if (is_array($post)){
ksort($post);
$context['http'] = array(
'method' => 'POST',
'header'=>"Cookie:".$_SERVER['HTTP_COOKIE']."
", //."
"
'content' => http_build_query($post, '', '&'),
);
$s_stream=stream_context_create($context);
}
return file_get_contents($url, false, $s_stream);
}
$url='http://localhost/090342/index.php?title=Property:Test_tom_1&action=submit';
$arr['wpTextbox1'] = 'This is a property of type [[Has type::String]].
The allowed values for this property are:
* [[Allows value::a]]
* [[Allows value::b]]
* [[Allows value::c]]
* [[Allows value::d]]
* [[Allows value::f]]';
$arr['wpSummary'] = '';
$arr['wpStarttime'] = '';
$arr['wpEdittime'] ='';
$arr['wpEditToken'] = "210b3e0e4bb96c28d356d8892527d6dc+";
$arr['wpSave'] ='';
print_r($arr);
//exit;
$result=Post($url, $arr);
var_dump($result);
本文永久链接:
http://www.zzxj.net/blog/fxs_2008/archive/2010/03/03/120.html
发表于 @
2010年03月03日 |评论(loading...
)|收藏