Как сделать HTTP-запросы в виде сообщения curl? - PullRequest
2 голосов
/ 16 марта 2019

Я сделал несколько HTTP-данных о несанкционированном вмешательстве и пытаюсь создать свою собственную запись завитков, но боюсь, что не могу понять, как эти вещи работают, кто-нибудь может объяснить, как мне их надеть?основываясь на моих достоверных данных о подделке в Firefox, существует три фазы для отправки данных на этом сайте, сначала это

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

, и после этого HTTP-заголовки, я думаю,

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

и, наконец,отправьте данные поста

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

Моя попытка с 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"

Вопрос: как мне сделать эти 3 HTTP-данных простым постом curl?

1 Ответ

1 голос
/ 16 марта 2019

Создайте ваши данные в виде ассоциативного массива для создания пар ключ / значение.

Создайте свои заголовки как массив.

Инициализация скручивания, установка необходимых параметров, выполнение, захват вывода, завершение скручивания, печать результатов.

<?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."\n");

?>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...