dqqvravff05370501 2019-03-16 15:55
浏览 55

如何将http请求作为卷曲帖子?

I have done some HTTP tamper data and trying to make my own curl post, but I'm afraid that I can't understand how these thing work, can anyone explain how do I put it on? based on my trustworthy tamper data on firefox there are three phases on submit data on this website, first is

URL : http://www.thisiswebsite.xyz/Nginx/script/order_handler.php
Method  POST
Type    xmlhttprequest
itemname : IFHPB-P14    
orderstep : 1

and after that a HTTP Headers i think

URL : http://www.thisiswebsite.xyz/Nginx/script/order_handler.php
Method  POST
Type    xmlhttprequest
Host : www.thisiswebsite
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0
Accept : text/html, */*; q=0.01
Accept-Language : en-US,en;q=0.5
Accept - Encoding : gzip, deflate
Referer : http://www.thisiswebsite/Nginx/index.php
Content-Type : application/x-www-form-urlencoded; charset=UTF-8 
X-Requested-With : XMLHttpRequest
Content-Length  : 30
Connection  : keep-alive
Cookie  : PHPSESSID=6gjfhn0475l26oanag1bugs025

and finally is the submit post data

URL : http://www.thisiswebsite.xyz/Nginx/script/order_handler.php
Method  POST
Type    xmlhttprequest
itemname : IFHPB-P14
orderstep : 3
username : testing
hdsn : datatest 
MAC  : datatestmac

My try with curl

curl -X POST http://www.thisiswebsite.xyz/Nginx/script/order_handler.php \ -H 'Host: www.thisiswebsite.xyz' \ -H 'Connection: keep-alive' \ -H 'Accept: text/html, */*; q=0.01' \ -H 'Accept-Language: en-US,en;q=0.5' \ -H 'Accept - Encoding: gzip, deflate' \ -H 'Referer: http://www.thisiswebsite.xyz/Nginx/index.php' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'X-Requested-With: XMLHttpRequest' \ -H 'Content-Length: 30' \ -H 'Cookie: PHPSESSID=6gjfhn0475l29oanagdbugs022' \ -A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0' \ --data "itemname=IFHPB-P4&orderstep=3&username=cahya&hdsn=123&MAC=123"

Question: how do I make this 3 HTTP Data to a simple curl post?

  • 写回答

1条回答 默认 最新

  • duan0708676887 2019-03-16 18:17
    关注

    Build your data as an associative array to make the key/value pairs.

    Build your headers as an array.

    Initialize curl, set the required options, execute, capture output, shut down curl, print results.

    <?php
    
    // build your data as an associative array for the keys
    // and yes, you can use multi-dimensional arrays, etc
    $data=array();
    $data['item']="abc123";
    $data['orderstep']=3;
    $data['username']="joe.user";
    $data['hsdn']=545;
    $data['MAC']="bigmac";
    
    // you can set options for various headers as needed, just
    // do all of them  as an array()
    $headers=array();
    $headers[]="Accept: text/html,*/*";
    $headers[]="Referer: http://some.example.com";
    $headers[]="Content-Type: application/x-www-form-urlencoded;charset=UTF-8";
    // and so on...
    
    // set the URL for your POST to go to
    $url="http://api.example.com/end/point";
    
    // now initialize curl
    $ch=curl_init();
    // set the options for your headers,
    curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
    // and http method
    curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"POST");
    // do you want to capture any returned output from server?
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    // what URL to call
    curl_setopt($ch,CURLOPT_URL,$url);
    // what data to send
    curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($data));
    // make it so!
    $curl_result=curl_exec($ch);
    // done with curl
    curl_close($ch);
    // show results
    print_r($curl_result."
    ");
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM