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

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

      <legend id='Jz2Be'><style id='Jz2Be'><dir id='Jz2Be'><q id='Jz2Be'></q></dir></style></legend>
        <bdo id='Jz2Be'></bdo><ul id='Jz2Be'></ul>

        <tfoot id='Jz2Be'></tfoot>
      1. 如何使用 curl 在 php 中调试 get 请求

        How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)

                <tbody id='wJU6s'></tbody>

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

                • <bdo id='wJU6s'></bdo><ul id='wJU6s'></ul>

                  <tfoot id='wJU6s'></tfoot>
                • <i id='wJU6s'><tr id='wJU6s'><dt id='wJU6s'><q id='wJU6s'><span id='wJU6s'><b id='wJU6s'><form id='wJU6s'><ins id='wJU6s'></ins><ul id='wJU6s'></ul><sub id='wJU6s'></sub></form><legend id='wJU6s'></legend><bdo id='wJU6s'><pre id='wJU6s'><center id='wJU6s'></center></pre></bdo></b><th id='wJU6s'></th></span></q></dt></tr></i><div id='wJU6s'><tfoot id='wJU6s'></tfoot><dl id='wJU6s'><fieldset id='wJU6s'></fieldset></dl></div>
                  <legend id='wJU6s'><style id='wJU6s'><dir id='wJU6s'><q id='wJU6s'></q></dir></style></legend>
                  本文介绍了如何使用 curl 在 php 中调试 get 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 curl 在 php 中发出一个 get 请求.这就是我正在做的:

                  I'm trying to make a get request in php using curl. This is what I'm doing:

                  $curl = curl_init();
                  
                  curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                  curl_setopt($curl, CURLOPT_USERPWD, "username:password");
                  
                  curl_setopt($curl, CURLOPT_URL, $url);
                  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                  
                  $result = curl_exec($curl);
                  curl_close($curl);
                  
                  printf($result);
                  

                  但是 $result 不打印任何内容,没有成功或失败的消息.我已经通过邮递员和网络浏览器成功到达端点,所以我知道它可以工作.打印 $curl 打印:"Resource #1" 这让我认为 curl 已正确安装在服务器上.

                  But $result doesn't print out anything, no success or failure message. I've successfully reached the endpoint via postman and in a web browser so I know it works. Printing out $curl prints: "Resource #1" which makes me think curl is properly installed on the server.

                  我不确定接下来要采取什么步骤来使事情顺利进行.

                  I'm not sure what steps to take next to make things work.

                  推荐答案

                  添加更多选项以进行故障排除.

                  Add a few more option for troubleshooting purposes.

                  检查错误响应.

                  如果没有错误,获取详细信息:

                  If no error, get the details:

                  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
                  curl_setopt($ch, CURLOPT_TIMEOUT,10);
                  curl_setopt($ch, CURLOPT_FAILONERROR,true);
                  curl_setopt($ch, CURLOPT_ENCODING,"");
                  
                  curl_setopt($ch, CURLOPT_VERBOSE, true);
                  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
                  curl_setopt($ch, CURLOPT_HEADER, true);
                  
                  $data = curl_exec($ch);
                  if (curl_errno($ch)){
                      $data .= 'Retreive Base Page Error: ' . curl_error($ch);
                  }
                  else {
                    $skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE)); 
                    $head = substr($data,0,$skip);
                    $data = substr($data,$skip);
                    $info = curl_getinfo($ch);
                    $info = var_export($info,true);
                  }
                  echo $head;
                  echo $info;
                  

                  这篇关于如何使用 curl 在 php 中调试 get 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                  PHP Require and Include GET(PHP 需要并包含 GET)

                      <tfoot id='oc3Yb'></tfoot>
                      • <bdo id='oc3Yb'></bdo><ul id='oc3Yb'></ul>

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

                        2. <legend id='oc3Yb'><style id='oc3Yb'><dir id='oc3Yb'><q id='oc3Yb'></q></dir></style></legend>

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