• <small id='Y264K'></small><noframes id='Y264K'>

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

      1. <tfoot id='Y264K'></tfoot>
          <bdo id='Y264K'></bdo><ul id='Y264K'></ul>

        <legend id='Y264K'><style id='Y264K'><dir id='Y264K'><q id='Y264K'></q></dir></style></legend>
      2. PHP:使用 cURL 模拟 XHR

        PHP: Simulate XHR using cURL(PHP:使用 cURL 模拟 XHR)
          • <bdo id='6p7BE'></bdo><ul id='6p7BE'></ul>

            <legend id='6p7BE'><style id='6p7BE'><dir id='6p7BE'><q id='6p7BE'></q></dir></style></legend>
            1. <tfoot id='6p7BE'></tfoot>
                <tbody id='6p7BE'></tbody>

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

                <small id='6p7BE'></small><noframes id='6p7BE'>

                  本文介绍了PHP:使用 cURL 模拟 XHR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  今天我正在尝试为某些论坛登录做一个 cron 作业以检查在线统计信息.login.php 脚本接受带有表单提交值的 ajax 请求:用户、密码、服务器和哈希 ID(在隐藏字段中).我已经可以将值提交到登录脚本,还可以使用 cookie jar 保留会话,但是当我尝试传递所需的参数(来自 sendlogin.php)时,它似乎拒绝了不带有正确请求标头的请求.所以我需要知道如何使用 cURL 进行模拟:

                  Today I'm trying to make a cron job for some forum login to check for online stats. The login.php script accepts an ajax request with the form submitted values: user, password, server, and a hash id (in a hidden field). I can already submit the values to the login script and also preserve the session using a cookie jar but when I try to pass the required parameters (coming from sendlogin.php), it seems to reject requests that do not come with the proper request headers. So I need to know how I could simulate this using cURL:

                  GET login.php?user=foo&password=bar&server=1&id=7131c359e534e3790eaefa495d621b2a HTTP/1.1
                  
                  Host: someloginserver.com
                  User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
                  Accept: application/json, text/javascript, */*; q=0.01
                  Accept-Language: en-us,en;q=0.5
                  Accept-Encoding: gzip, deflate
                  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
                  Keep-Alive: 115
                  Connection: keep-alive
                  X-Requested-With: XMLHttpRequest
                  Referer: http://someloginserver.com/sendlogin.php
                  Cookie: __cfduid=de2fe207593d1135fc2426fb06e3270741303115848; hellobar_current=1300711502; hellobar_1300711502_variation=11462; PHPSESSID=cc621c6f57c43130d51d3147e319d8c2
                  

                  希望你能帮助我.

                  推荐答案

                  在PHP api to curl你可以使用:

                  In the PHP api to curl you can use:

                  curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                      "Host" => "someloginserver.com",
                      "User-Agent" => "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
                      "Accept" => "application/json, text/javascript, */*; q=0.01",
                      "Accept-Language" => "en-us,en;q=0.5",
                      "Accept-Encoding" => "gzip, deflate",
                      "Accept-Charset" => "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
                      "Keep-Alive" => "115",
                      "Connection" => "keep-alive",
                      "X-Requested-With" => "XMLHttpRequest",
                      "Referer" => "http://someloginserver.com/sendlogin.php"
                  ));
                  

                  但您的实际问题可能是我在上面排除的 Cookie:.使用 COOKIEJAR 设置您的 cURL 请求.发出一个虚假请求以获取当前会话值,然后才发送您的实际 XHR 请求.

                  But your actual problem might be the Cookie:, which I've excluded above. Setup your cURL request with a COOKIEJAR. Make one faux request to get a current session value, and only afterwards send your actual XHR request.

                  这篇关于PHP:使用 cURL 模拟 XHR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                  Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                  Doctrine 2, query inside entities(原则 2,实体内部查询)
                  Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                  Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                  Doctrine and unrefreshed relationships(教义和未更新的关系)

                            <tbody id='wWBKC'></tbody>

                          • <bdo id='wWBKC'></bdo><ul id='wWBKC'></ul>
                          • <small id='wWBKC'></small><noframes id='wWBKC'>

                          • <legend id='wWBKC'><style id='wWBKC'><dir id='wWBKC'><q id='wWBKC'></q></dir></style></legend>

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