Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中使用文件获取内容_Php_Post_Geoserver - Fatal编程技术网

在php中使用文件获取内容

在php中使用文件获取内容,php,post,geoserver,Php,Post,Geoserver,我尝试使用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("ht

我尝试使用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新手,所以我可能在这里做错了什么?找到此代码snipet i。

您可以尝试不使用端口吗??例如:

$geoserverURL = "http://localhost/geoserver/j_acegi_security_check";

您不会在firebug中看到它,因为firebug会记录在您一侧(客户端)的事件,这意味着在您的浏览器中。如果使用ajax,那么您可以跟踪它,然后firebug会记录它

如果您想检查它的轨迹,请使用工具控制您的网络,例如WireShark。在那里,您将能够记录此请求


如果您需要使用登录名和密码,我建议您使用cURL。更好的是,IMO

您似乎对PHP是如何执行代码的存在误解。在到达任何地方之前,您需要跟踪服务器端代码是什么。PHP代码在服务器上运行,而不是在浏览器中,因此您不会在Firebug中看到任何内容。有关更多信息,请参阅此问题:无端口i get错误:
警告:文件\u get\u内容(http://localhost/geoserver/j_acegi_security_check):在第64行的D:\xampp\htdocs\rest\index.php中
。所以,如果我理解正确的话,这意味着端口文件的内容()参见重新查询页面?@KliverMax如果您没有得到任何响应,我猜url、端口或类似的问题。首先,您需要检查您的请求是否指向正确的url,并且您是否有任何响应