获取需要在PHP中进行身份验证的页面内容 [英] Get page content that required authentication in PHP

查看:101
本文介绍了获取需要在PHP中进行身份验证的页面内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得需要验证(用户名和密码)的页面的内容,我只能使用有效的用户名和密码访问此页面,我想使用PHP库访问此页面。你可以建议一个方法或库,我可以访问此页面。谢谢 。

I want to get the content of page which required authentication (username and password ) , i can only access this page using valid username and password , i want to access this page using php library. can you please suggest a method or library using which i can access this page. Thanks .

推荐答案

尝试:

//CHANGE THIS
$username='YOUR_USERNAME';
$password='YOUR_PASSWORD';
$location='http://YOUR_ADDRESS/YOUR_FILE.php';


$ch = curl_init ();
curl_setopt($ch,CURLOPT_URL,$location);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch, CURLOPT_TIMEOUT, 10);

$result = curl_exec ($ch); 

这篇关于获取需要在PHP中进行身份验证的页面内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆