【发布时间】:2013-08-26 06:34:35
【问题描述】:
我尝试使用 php 登录 Geoserver。我愿意:
$geoserverURL = "http://localhost:8080/geoserver/j_acegi_security_check";
$post = http_build_query(array(
"username" => $username,
"password" => $password,
));
$context = stream_context_create(array("http"=>array(
"method" => "POST",
"header" => "Content-Type: application/x-www-form-urlencoded\r\n" .
"Content-Length: ". strlen($post) . "\r\n",
"content" => $post,
)));
$page = file_get_contents($geoserverURL, false, $context);
echo $page;
但在 FireBug 中看不到任何活动。我是 php 新手,所以也许我在这里做错了什么?这个代码片段我被发现here。
【问题讨论】:
-
您似乎对 PHP 是如何执行该代码有误解。在到达任何地方之前,您需要跟踪服务器端代码是什么。 PHP 代码在服务器上运行,而不是在您的浏览器中,因此您不会在 Firebug 中看到任何内容。有关更多信息,请参阅此问题:stackoverflow.com/questions/7407374/…