curl从外部网站获取价值需要用户名和密码(curl get value from outside website need username and password)
我想在网站外获取一些需要用户名和密码的价值表格。 通常我需要先登录页面( https://xxx.xxx.xxx/HomeAccess ),然后转到https://xxx.xxx.xxx/xxx.aspx 。 但如果没有登录只是转到页面xxx.aspx,我会得到错误“由于发生内部服务器错误,页面无法显示。”;
在PHP中我正在尝试使用此代码
<?php $ch = curl_init(); $url = 'https://xxx.xxx.xxx/xxx.aspx'; $username ='uuuuu'; $password ='ppppp'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); print $output; ?>
我有空白页面。
任何想法? 谢谢
I am trying to get some value form outside website which need username and password. normally I need go to login page first(https://xxx.xxx.xxx/HomeAccess), then go to https://xxx.xxx.xxx/xxx.aspx. But if without login just go to the page xxx.aspx, I will get errror "The page cannot be displayed because an internal server error has occurred.";
in PHP I'm trying use this code
<?php $ch = curl_init(); $url = 'https://xxx.xxx.xxx/xxx.aspx'; $username ='uuuuu'; $password ='ppppp'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); print $output; ?>
I got blank page.
Any idea? thanks
原文:https://stackoverflow.com/questions/15142025
最满意答案
从结构上讲,您显示的查询生成器查询看起来很好。
看起来不太好的是
left join
。 不应该这样:->leftJoin('permission_role', 'permission_role.permission_id', '=', 'permission_role.role_id')
是这样的:
->leftJoin('permission_role', 'permission_role.permission_id', '=', 'permissions.id')
?
Structurally, the Query Builder query you've shown looks fine.
What does not look fine is the
left join
. Shouldn't this:->leftJoin('permission_role', 'permission_role.permission_id', '=', 'permission_role.role_id')
be this:
->leftJoin('permission_role', 'permission_role.permission_id', '=', 'permissions.id')
?
相关问答
更多-
如果$ids是一个数组 您可以通过以下方式获得结果 Device::whereIn('id', $ids)->where('status', 'active')->get(['id', 'pushbadge', 'pushalert', 'pushsound']); if $ids is an array you can get your result with something as below Device::whereIn('id', $ids)->where('status', 'active') ...
-
`Where`子句返回空列表,即使逻辑测试是'true`(`Where` clause returns empty list even if the logic test is `true`)[2023-05-17]
什么是_logicTest ? 财产? 如果是这样,它可能会在评估集合时发生变化。 而且Where的返回值是IEnumerable。 只有在使用集合时才会评估实际值(例如,在foreach循环中)。 您可以尝试在Where的末尾添加ToList()或ToArray() 。 这样就可以立即评估集合,并且可以查看执行getter时是否真的没有项目。 另一种选择是VS调试器。 在监视表中,您可以使用小刷新图标评估集合。 这样你也可以看到“真实”的物品。 但是如果您稍后使用该集合(例如在foreach循环中 ... -
放置这个 ->where('valid_licence_id', '1') 走出封闭。 ->where('valid_licence_id', '1') ->where(function ($query) { $query->where('statut_licence_id' , '4') ->orWhere('statut_licence_id' , '1'); })->orderBy('created_at', 'DESC')->paginate(10); Place this -> ...
-
从结构上讲,您显示的查询生成器查询看起来很好。 看起来不太好的是left join 。 不应该这样: ->leftJoin('permission_role', 'permission_role.permission_id', '=', 'permission_role.role_id') 是这样的: ->leftJoin('permission_role', 'permission_role.permission_id', '=', 'permissions.id') ? Structurally, ...
-
尝试这个: $Quote = Quote::with(['Customer' => function($Query) use ($searchQuery) { $Query->where('e_mail', 'LIKE', '%'.$searchQuery.'%'); }])->where('trashed', '0')->where('item', 'LIKE', '%'.$searchQuery.'%'); I managed to solve this ...
-
在这种情况下,您可以使用: ->where('updated_at', '>=', DB::raw('DATE_SUB(NOW(), INTERVAL 30 DAY)')) 正如@ user2486已经提到的那样,但对于这种情况,我更喜欢这种方式: ->whereRaw('updated_at >= DATE_SUB(NOW(), INTERVAL 30 DAY)'); 对我来说,阅读起来有点干净。 In such case you can use: ->where('updated_at', '>=' ...
-
尝试: query = { } query[:class_name] = courses if courses.present? query[:year] = years if years.present? query[:resource_type] = coursresourceTypeses if coursresourceTypeses.present? @resources = Resource.where(query).paginate(page: params[:page], per_pag ...
-
我会建议更像这样的东西。 首先,检查是否首先设置$_POST['login'] ,这样如果尚未点击提交按钮,则不会检查其他任何内容。 然后在其中,验证是否已输入用户名和密码。 如果他们有,继续,但你要验证他们。 if (isset($_POST['login'])) { if (empty($_POST['username']) || empty($_POST['password'])) { echo 'required field'; } else { if ...
-
因为MySQL将true转换为1,所以您的实际查询与以下内容相同: select * from employee where id = 1 Because MySQL casts true into 1, so your actual query is the same as: select * from employee where id = 1
-
你必须筑巢这些,还为什么你想要那里的那个? ->whereHas('Group', function($q) { $q->where(function ($q) { $q->where('GroupId', 'KO11')->orWhere('GroupId', 'KO05'); }); }) 因为whereHas增加了where fk = ? and ... where fk = ? and ... 其他方式是: $q->whereRaw("(GroupId = 'KO11 ...