簡體   English   中英

如何通過用戶名和密碼訪問安全區域

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

我想訪問這個頁面,它在輸入正確的用戶名和密碼后返回一個 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

提前致謝

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

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

您可以在 php 中以多種方式執行此操作。

如果您碰巧在 linux 環境中托管您的代碼或具有本機 curl 支持,您可以

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

或者您可以使用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