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 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                      <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>