<legend id='ZNXU0'><style id='ZNXU0'><dir id='ZNXU0'><q id='ZNXU0'></q></dir></style></legend>
      1. <small id='ZNXU0'></small><noframes id='ZNXU0'>

      2. <tfoot id='ZNXU0'></tfoot>

        <i id='ZNXU0'><tr id='ZNXU0'><dt id='ZNXU0'><q id='ZNXU0'><span id='ZNXU0'><b id='ZNXU0'><form id='ZNXU0'><ins id='ZNXU0'></ins><ul id='ZNXU0'></ul><sub id='ZNXU0'></sub></form><legend id='ZNXU0'></legend><bdo id='ZNXU0'><pre id='ZNXU0'><center id='ZNXU0'></center></pre></bdo></b><th id='ZNXU0'></th></span></q></dt></tr></i><div id='ZNXU0'><tfoot id='ZNXU0'></tfoot><dl id='ZNXU0'><fieldset id='ZNXU0'></fieldset></dl></div>
          <bdo id='ZNXU0'></bdo><ul id='ZNXU0'></ul>

      3. 服务器端的 CURL HTTP 身份验证

        时间:2023-10-02
          <bdo id='ydjFY'></bdo><ul id='ydjFY'></ul>

          <small id='ydjFY'></small><noframes id='ydjFY'>

            <tfoot id='ydjFY'></tfoot>
          • <legend id='ydjFY'><style id='ydjFY'><dir id='ydjFY'><q id='ydjFY'></q></dir></style></legend>
              <tbody id='ydjFY'></tbody>

            • <i id='ydjFY'><tr id='ydjFY'><dt id='ydjFY'><q id='ydjFY'><span id='ydjFY'><b id='ydjFY'><form id='ydjFY'><ins id='ydjFY'></ins><ul id='ydjFY'></ul><sub id='ydjFY'></sub></form><legend id='ydjFY'></legend><bdo id='ydjFY'><pre id='ydjFY'><center id='ydjFY'></center></pre></bdo></b><th id='ydjFY'></th></span></q></dt></tr></i><div id='ydjFY'><tfoot id='ydjFY'></tfoot><dl id='ydjFY'><fieldset id='ydjFY'></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 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:.zfproject.xml 在 Zend Framework 项目中是必须的吗? 下一篇:使用 Doctrine 2 转储数据库数据

                  相关文章

                  最新文章

                  1. <tfoot id='Q1sm5'></tfoot>

                        <bdo id='Q1sm5'></bdo><ul id='Q1sm5'></ul>

                      <small id='Q1sm5'></small><noframes id='Q1sm5'>

                      <i id='Q1sm5'><tr id='Q1sm5'><dt id='Q1sm5'><q id='Q1sm5'><span id='Q1sm5'><b id='Q1sm5'><form id='Q1sm5'><ins id='Q1sm5'></ins><ul id='Q1sm5'></ul><sub id='Q1sm5'></sub></form><legend id='Q1sm5'></legend><bdo id='Q1sm5'><pre id='Q1sm5'><center id='Q1sm5'></center></pre></bdo></b><th id='Q1sm5'></th></span></q></dt></tr></i><div id='Q1sm5'><tfoot id='Q1sm5'></tfoot><dl id='Q1sm5'><fieldset id='Q1sm5'></fieldset></dl></div>
                    1. <legend id='Q1sm5'><style id='Q1sm5'><dir id='Q1sm5'><q id='Q1sm5'></q></dir></style></legend>