Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用ASP.NET的授权HTTP头_Php_Asp.net_.net_Curl - Fatal编程技术网

Php 使用ASP.NET的授权HTTP头

Php 使用ASP.NET的授权HTTP头,php,asp.net,.net,curl,Php,Asp.net,.net,Curl,我想使用asp.net创建一个授权http头,如果我想使用php+curl,我有文档中给出的代码,这里是链接 我不想在我的IIS上安装php,只想在.net环境中工作。有人能给asp提供以下代码的替代方案吗: $botkey='[999999]'; $from="14075551212"; $userKey = $_REQUEST['userkey']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://api.messag

我想使用asp.net创建一个授权http头,如果我想使用php+curl,我有文档中给出的代码,这里是链接

我不想在我的IIS上安装php,只想在.net环境中工作。有人能给asp提供以下代码的替代方案吗:

$botkey='[999999]';

$from="14075551212";

$userKey = $_REQUEST['userkey'];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://api.messaging.staging.voxeo.net/1.0/messaging');

curl_setopt($ch, CURLOPT_HEADER, 0);

$data="botkey=".$botkey."&apimethod=send&msg=".$msg."&userkey=".$userKey."&network=SMS&   from=".$from;

curl_setopt($ch, CURLOPT_USERPWD, '[Evolution User Name]:[Evolution Password]');

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

c    url_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_TIMEOUT, 100);
我需要ASP.net来替代下面的curl

curl -u MyUserName:MyPassword "http://api.messaging.staging.voxeo.net/1.0/messaging" -X POST -d "botkey=12345&apimethod=send&msg=My%20test%20message.&user=14075555555&network=SMS&from=14076666666"

我不确定我是否完全理解你的意思,但为了让flash进入我应用程序的安全部分,我必须这么做。我有更多的检查,为了清晰起见,我已经删除了这些检查,但是如果您需要的话,这将创建一个授权cookie。我必须问一下,为什么你不能在ASP.NET中使用普通的身份验证方法呢

void Application_BeginRequest(object sender, EventArgs e)
{
    string SessionParamName = "";
    string SessionCookieName = "";
    string AuthParamName = "";
    string AuthCookieName = "";

    try
    {
        SessionParamName = "ASPSESSID";
        SessionCookieName = "ASP.NET_SessionId";
        if (HttpContext.Current.Request.Form[SessionParamName] != null)
            UpdateCookie(SessionCookieName, HttpContext.Current.Request.Form[SessionParamName]);
        else if (HttpContext.Current.Request.QueryString[SessionParamName] != null)
            UpdateCookie(SessionCookieName, HttpContext.Current.Request.QueryString[SessionParamName]);
    }
    catch { }

    try
    {
        AuthParamName = "AUTHID";
        AuthCookieName = FormsAuthentication.FormsCookieName;
        if (HttpContext.Current.Request.Form[AuthParamName] != null)
            UpdateCookie(AuthCookieName, HttpContext.Current.Request.Form[AuthParamName]);
        else if (HttpContext.Current.Request.QueryString[AuthParamName] != null)
            UpdateCookie(AuthCookieName, HttpContext.Current.Request.QueryString[AuthParamName]);
    }
    catch { }
}

private void UpdateCookie(string CookieName, string CookieValue)
{
    HttpCookie Cookie = HttpContext.Current.Request.Cookies.Get(CookieName);
    if (Cookie == null)
        Cookie = new HttpCookie(CookieName);

    Cookie.Value = CookieValue;
    HttpContext.Current.Response.Cookies.Add(Cookie);
}

我不知道我是否可以使用asp.net的正常身份验证方法,因为教程没有提到它。我想大多数服务器不接受直接授权,需要设置一个标题或cookie。这个网站把它写在“身份验证”标题下。这就是我想要实现的,实际上你是想在“他们的”应用程序上验证你自己吗?