1

I have a working javascript/jQuery REST app with the webtrends' exctraction API, with the exception of IE.

I am sending authentication via SSL - https://[domainname]\[username]:[password]@ws.webtrends.com/v3/Reporting/profiles/10609/Keymetrics/?start_period=current_day-1&end_period=current_day&period_type=agg&format=json

When I look inside of Developer Tools (F12) > under the Network tab, Internet Explorer changes the backslash('\') to a forward slash ('/'), which results in the browser looking for a web site with the value of the domainname.

All other browsers do NOT change the backslash.

    $.ajaxSetup({
        crossDomain: true,
        async: false,
        contentType: "application/jsonp",
        dataType: "jsonp",
        type: "POST",
        cache: false,
        beforeSend: function(xhr) {
          xhr.overrideMimeType("application/jsonp; charset=UTF-8");
        },
        headers: {
            "Authorization": mBaseSixtyFourVar
        },
        url: mXferObj.mUrl
    });

    $.ajax({ 
        success: function(mInfo){        
            mRecvObj = mInfo;
            alert(mRecvObj.data[0].measures.NewVisitors+"");
        },
        error: function (xmlHttpRequest, textStatus, errorThrown) {
            alert("xmlHttpRequest.readyState: "+xmlHttpRequest.readyState+", textStatus: "+textStatus+", errorThrown: "+errorThrown+", mXferObj.mUrl: "+mXferObj.mUrl);
        }
    });

I have tried the following:

Inserting this into the ajaxsetup

data: "{'domain':'domainname','username':'blabla','password':'blabla'}",

With PHP, I have tried using curl, but nothing returned except bool(false):

I tried file_get_contents() but I received open stream errors.

I have this working in FireFox, Opera, Safari, Chrome - why is IE always the hold up to perfection?

Any help would be appreciated and thanks in advance

As requested, here is ONE of the curL codes that I have tried:

if (!function_exists('curl_init')){ 
    die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
var_dump $output;

I have tried the options:

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(CURLOPT_USERPWD, '[username]:[password]') 

So many different things that I have tried, that was the last

4

1 回答 1

0

更新

鉴于您对在 中提供用户名和密码的评论XMLHTTPRequest,我做了一些研究,发现 jQuery确实支持此功能。您所要做的就是将usernamepassword参数添加到您的请求中:

$.ajaxSetup({
    crossDomain: true,
    async: false,
    contentType: "application/jsonp",
    dataType: "jsonp",
    type: "POST",
    cache: false,
    beforeSend: function(xhr) {
      xhr.overrideMimeType("application/jsonp; charset=UTF-8");
    },
    headers: {
        "Authorization": mBaseSixtyFourVar
    },
    url: mXferObj.mUrl,
    username: "yourUsername",
    password: "yourPassword"
});

原始答案

简而言之,Internet Explorer 不支持此功能。它在 2004 年发布的先前安全更新中被删除:

http://support.microsoft.com/kb/834489

默认情况下,从安全更新 832894 开始发布的 Windows Internet Explorer 版本不支持在 HTTP 和使用安全套接字层 (SSL) 或 HTTPS URL 的 HTTP 中处理用户名和密码。Internet Explorer 或 Windows Explorer 不支持以下 URL 语法:http(s)://username:password@server/resource.ext

替代方案可能包括向您自己的服务器发出 AJAX 请求,然后在服务器端使用托管代码执行请求。例如,如果您选择的语言是 C#,您可以使用HttpWebRequest并提供适当的NetworkCredentials信息来完成请求。

于 2013-05-03T21:39:59.770 回答