<bdo id='9u5mU'></bdo><ul id='9u5mU'></ul>

    <small id='9u5mU'></small><noframes id='9u5mU'>

    <tfoot id='9u5mU'></tfoot>
    <legend id='9u5mU'><style id='9u5mU'><dir id='9u5mU'><q id='9u5mU'></q></dir></style></legend>

      1. <i id='9u5mU'><tr id='9u5mU'><dt id='9u5mU'><q id='9u5mU'><span id='9u5mU'><b id='9u5mU'><form id='9u5mU'><ins id='9u5mU'></ins><ul id='9u5mU'></ul><sub id='9u5mU'></sub></form><legend id='9u5mU'></legend><bdo id='9u5mU'><pre id='9u5mU'><center id='9u5mU'></center></pre></bdo></b><th id='9u5mU'></th></span></q></dt></tr></i><div id='9u5mU'><tfoot id='9u5mU'></tfoot><dl id='9u5mU'><fieldset id='9u5mU'></fieldset></dl></div>
      2. 服务器端的 CURL HTTP 身份验证

        CURL HTTP Authentication at server side(服务器端的 CURL HTTP 身份验证)
        <legend id='v32Vj'><style id='v32Vj'><dir id='v32Vj'><q id='v32Vj'></q></dir></style></legend>
      3. <small id='v32Vj'></small><noframes id='v32Vj'>

          <tfoot id='v32Vj'></tfoot>

              <bdo id='v32Vj'></bdo><ul id='v32Vj'></ul>
                  <tbody id='v32Vj'></tbody>

                  <i id='v32Vj'><tr id='v32Vj'><dt id='v32Vj'><q id='v32Vj'><span id='v32Vj'><b id='v32Vj'><form id='v32Vj'><ins id='v32Vj'></ins><ul id='v32Vj'></ul><sub id='v32Vj'></sub></form><legend id='v32Vj'></legend><bdo id='v32Vj'><pre id='v32Vj'><center id='v32Vj'></center></pre></bdo></b><th id='v32Vj'></th></span></q></dt></tr></i><div id='v32Vj'><tfoot id='v32Vj'></tfoot><dl id='v32Vj'><fieldset id='v32Vj'></fieldset></dl></div>
                • 本文介绍了服务器端的 CURL HTTP 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Zend 构建 Web 服务,我必须在向用户发送响应之前对其进行身份验证.用户将使用 curl 向服务器页面发送请求,并以 curl_setopt($curl, CURLOPT_USERPWD, 'key:pass');

                  I am building a web service with Zend and i have to authenticate the users before sending them response. The user will send a request to a server page, using curl, passing his credentials in the form of curl_setopt($curl, CURLOPT_USERPWD, 'key:pass');

                  我使用 Zend 框架,因此服务器端页面表示为:

                  Iam using Zend framework and so the server side page is denoted like:

                  http://www.example.com/app_name/public/controller/action/parameter

                  这里是用户请求的总代码(client.php):

                  Here is the total code for user's request (client.php):

                  <?php
                  $curl = curl_init('http://www.example.com/app/public/user/add/1');
                  
                  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);                         
                  curl_setopt($curl, CURLOPT_USERPWD, 'username:password');
                  curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);                    
                  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);                          
                  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);                           
                  curl_setopt($curl, CURLOPT_USERAGENT, 'Sample Code');
                  
                  $response = curl_exec($curl);                                          
                  $resultStatus = curl_getinfo($curl);                                   
                  
                  if($resultStatus['http_code'] == 200) {
                      echo $response;
                  } else {
                      echo 'Call Failed '.print_r($resultStatus);                         
                  }
                  
                  ?>
                  

                  现在我想要的是,我必须能够在服务器端(在我的 Zend 控制器中)检索用户名和密码,以便我可以验证数据库中的用户凭据并相应地发送响应.那么如何在另一个页面中进行身份验证?

                  Now what i want is that, i must be able to retrieve the username and password at the server side (in my zend controller), so that i can verify the user credentials from database and send the response accordingly. So how can i do authentication in another page?

                  推荐答案

                  Zend Framework 有一个现成的组件来处理 HTTP 身份验证.

                  Zend Framework has a ready-made component for handling HTTP authentication.

                  • http://framework.zend.com/manual/en/zend.auth.adapter.http.html

                  如果你不想使用它,你仍然可以走老派"的方式,如

                  If you don't want to use that, you can still go the "old-school" way, as described in

                  • http://php.net/manual/en/features.http-auth.php

                  并手动检查 $_SERVER['PHP_AUTH_USER']$_SERVER['PHP_AUTH_PW']

                  这篇关于服务器端的 CURL HTTP 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Zend_Controller_Router_Exception: quot;xyzquot; is not specified(Zend_Controller_Router_Exception:“xyz;未指定)
                  Zend_Db_Table subquery(Zend_Db_Table 子查询)
                  pcntl_fork and the MySQL connection is gone(pcntl_fork 和 MySQL 连接消失了)
                  Change layout in the controller of Zend Framework 2.0(在 Zend Framework 2.0 的控制器中更改布局)
                  Zend Mail Gmail SMTP(Zend 邮件 Gmail SMTP)
                  Zend_Form: how to check 2 fields are identical(Zend_Form:如何检查 2 个字段是否相同)
                  <i id='yZw5q'><tr id='yZw5q'><dt id='yZw5q'><q id='yZw5q'><span id='yZw5q'><b id='yZw5q'><form id='yZw5q'><ins id='yZw5q'></ins><ul id='yZw5q'></ul><sub id='yZw5q'></sub></form><legend id='yZw5q'></legend><bdo id='yZw5q'><pre id='yZw5q'><center id='yZw5q'></center></pre></bdo></b><th id='yZw5q'></th></span></q></dt></tr></i><div id='yZw5q'><tfoot id='yZw5q'></tfoot><dl id='yZw5q'><fieldset id='yZw5q'></fieldset></dl></div>
                    <tbody id='yZw5q'></tbody>
                      <bdo id='yZw5q'></bdo><ul id='yZw5q'></ul>

                          1. <small id='yZw5q'></small><noframes id='yZw5q'>

                          2. <legend id='yZw5q'><style id='yZw5q'><dir id='yZw5q'><q id='yZw5q'></q></dir></style></legend>
                          3. <tfoot id='yZw5q'></tfoot>