简体   繁体   English

如何通过用户名和密码访问安全区域

[英]how to access a secure area passing username and password

I want to access this page which returns an xml file after entering the correct username and password http://webservices.ns.nl/ns-api-avt?station=ut I want to pass this xml to flash but I don't know how to pass the username and password I am looking forward to something like that username:password@webservices.ns.nl/ns-api-avt?station=ut or using php here the site url of that api if it helps http://www.ns.nl/api/api我想访问这个页面,它在输入正确的用户名和密码后返回一个 xml 文件http://webservices.ns.nl/ns-api-avt?station=ut我想将此 xml 传递给 flash,但我没有知道如何传递用户名和密码我期待像这样的用户名:password@webservices.ns.nl/ns-api-avt?station=ut 或在此处使用 php 该 api 的站点 url 如果它有帮助http: //www.ns.nl/api/api

thanks in advance提前致谢

php.net 上带有 curl 的 PHP 示例: http ://www.php.net/manual/en/function.curl-setopt.php#98164 有趣的部分是:

curl_setopt($curl, CURLOPT_USERPWD, "username:password"); 

You can do this in several ways in php..您可以在 php 中以多种方式执行此操作。

if you happen to host your code in a linux env or has a native curl support, you can如果您碰巧在 linux 环境中托管您的代码或具有本机 curl 支持,您可以

$call = "curl --basic --user {$username}:{$password} \"{$url}\"";
exec($call, $resp);
print_r($resp);

or you can use the module class.http.php from HTTP Library或者您可以使用HTTP 库中的模块class.http.php

$http = new Http();
$http->useCurl(false);
$http->setMethod($method);
$http->setAuth($user, $pass);
$http->execute($url);
$resp = $http->error ? $http->error : $http->result;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM